Re: Reoccurring task manager
| From: | Daniel Brown | Date: | Fri, 15 Jun 2007 20:38:39 +0000 |
| Subject: | Re: Reoccurring task manager | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257126@lists.php.net to get a copy of this message | ||
On 6/15/07, Jason Pruim <japruim@raoset.com> wrote:
[PHP] 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.... } ?> I need to learn more about arrays so I don't have to type out all of my data! :P But first, I'll get it working and then I'll redo it. It's a good exercise for me.Actually, this is output as $row['column_name'] from mysql_fetch_array();, so if the row is
task_id, the variable for
each row from the while() condition would be $row['task_id'];.
Otherwise, try this:
<?
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
extract($row);
// Now you can just call the column name as a variable.
// echo $task_id;
}
?>
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()); ?> Currently when I try and pass the variable from viewall.php to update.php by doing a <a href="update.php?$row[0]"> Click here!</A> I'm getting this error: "[Fri Jun 15 16:10:10 2007] [error] PHP Notice: Undefined index: taskid in update.php on line 4" and line 4 from the script looks like this: $task_id = $_POST['taskid']; //Passed from the HTML-ized area of cron.php Am I just totally missing something and making a very stupid newbie mistake? Or have I stumbled onto something that is at least mildly hard?It looks as though you're trying to use a variable as a query string. Change the link from:
<a href="update.php?$row[0]">Click here</A>.... to:
<a href="update.php?taskid=<?=$row[0];?>">Click here</a>.... and then changing:
$task_id = $_POST['taskid']; //Passed from the HTML-ized areaof cron.php .... to:
$task_id = $_REQUEST['taskid']; // This now accepts POST and GET
NOTE: This was entirely typed directly into the mail client, and NONE of it was tested, so it probably has tons of bugs. Actually, if I am reading it right, it doesn't have too many! :)Glad to hear it worked for you.
Jason "Waiting for his Top Shelf liquor" PruimJust remember, if you come to the wedding reception in the spring, you have to pay for your own flight (unless you're in driving distance of Scranton, Pennsylvania). Other than that, the liquor shall certainly flow.... it's going to have to in order to get me up to the altar. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107