Re: Reoccurring task manager

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[MySQL]
   L> Table: `tasks`
       L> Columns: `id` (auto_increment), `task_name`, `completed`,
`day_of_week`


   L> File: viewall.php
<?
// .... Include files, connection routines, configuration, blah, blah, blah....
$dow = (date("N") - 1);

$sql  = "SELECT task_name FROM tasks WHERE completed='0'";
$sql .= " AND (day_of_week BETWEEN '0' AND '".$dow."')";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
   // .... Your routine for HTML-izing the output from the database....
}
?>

   L> File: update.php
<?
// .... More include stuff, blah, blah, blah....
$task_id = $_POST['task_id']; // Passed from the "HTML-ized" area of cron.php
$sql = "UPDATE tasks SET completed='1' WHERE id='".$task_id."' LIMIT 1;";
mysql_query($sql) or die(mysql_error());
?>

   L> File: cronjob.php
<?
// .... Guess what goes here!....
$dow = (date("N") - 1);
$sql = "UPDATE tasks SET completed='0' WHERE day_of_week='".$dow."'';
mysql_query($sql);
?>

[cron]
40 03 * * * /path/to/cronjob.php >> /dev/null 2>&1


NOTE: This was entirely typed directly into the mail client, and NONE
of it was tested, so it probably has tons of bugs.

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux