Re: task Scheduler driving me crazy!

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

 



Jason Pruim wrote:
Hi Everyone!

Okay, so for those of you who remember I have been going back and forth on how to write a reoccuring task manager program for my office, it's a little bit a labor of love, little bit wanting to expand my knowledge.

Anyway, I've hit a problem... I am attempting to add away to reschedule tasks based on a value entered in a text box (IE: 7/3/07) and then create a timestamp off of that so that I can have it show up on that date.

The problem comes in when I try and submit the values to the update form, as of right now, it only picks up the info in the bottom text box and updates it.... None of the others, no matter how many/few I have selected to update.

I think I need to put the text boxes into an array (And possibly the check boxes as well) but I have never done that before for text boxes.. Is it as easy as textbox[] to create an array of text boxes? Or is there something else that I'm missing?

Here is some of the code:

$result = mysql_query($sql);
echo "<form method='POST' action='update.php' name='ticklers'>";
echo "<table border='1' bgcolor=".$tableBody." >";
echo "<tr>
<TH>ID #</TH>
<th>Tickler Name</th>
<th>Tickler Description</th>
<TH>Completed</th>
<TH> Day to complete</th>
<TH>Reschedule Date</TH>
</tr>";

while($row = mysql_fetch_array($result)) {


    echo "<TR><TD bgcolor=".$rowColor.">ID#, $row[0] </td>";// ID #
echo "<td bgcolor=".$rowColor.">TicklerName, $row[1] </td>";// Tickler Name echo "<td bgcolor=".$rowColor.">Instructions, <A href='$row[2]'>Instructions</A></td>";// Instructions echo "<td bgcolor=".$dowColor.">DayOfWeekWord, $dowword </td>";// Day of week word echo "<TD BGCOLOR=".$rowColor.">DateToReschedule, <input type='text' name='txtReschedule' value=''>";//Date to reschedule echo "<TD BGCOLOR=".$rowColor.">DateRescheduled, $Date";//Date stored in timeStamp // echo "<TD bgcolor=".$rowColor."><A href='update.php?taskid=$row[0]&taskdate=$taskdate'>Click here!</A>"; echo "<TD bgcolor=".$rowColor.">CheckboxForWhenDone, <input type='checkbox' name='chkDone' value='$row[0]'>";//Check box for when completed

}

First off, I would use the heredoc syntax for this chuck of code.

also if you are going to use the indexes of $row, then use mysql_fetch_row() instead of *_array()
Won't chew up as much resources. I would recommend that you use *_assoc() instead, this way you can call to the column name and not have to rely on the DB layout never changing.

while($row = mysql_fetch_row($result)) {

echo <<<HTML

<tr>
	<td class="{$rowColor}">ID#, {$row[0]} </td>
	<td class="{$rowColor}">TicklerName, {$row[1]}  </td>
	<td class="{$rowColor}">Instructions, <a href='{$row[2]}'>Instructions</a></td>
	<td class="{$dowColor}">DayOfWeekWord, {$dowword} </td>
	<td class="{$rowColor}">DateToReschedule,
		<input type='text' name='tasks[{$row[0]}][txtReschedule]' value=''></td>
	<td class="{$rowColor}">DateRescheduled, {$Date}</td>
	<td class="{$rowColor}"><a
		href='update.php?taskid={$row[0]}&taskdate={$taskdate}'>Click here!</a></td>
	<td class="{$rowColor}">CheckboxForWhenDone,
		<input  type='checkbox' name='tasks[{$row[0]}][chkDone]' value='{$row[0]}'></td>
</tr>

HTML;

}



and the update form:


if ( isset($_POST['tasks']) && count($_POST['tasks']) > 0 ) {
	foreach ( $_POST['tasks'] AS $id => $attributes ) {
		if ( isset($attributes['chkDone']) && $attributes['chkDone'] == $id ) {
			$id = mysql_real_escape_string((int)$id);
			$SQL = "UPDATE	tasks
				SET	completed='1',
					timeStamp=NOW()  -- Assuming DATE/TIME/etc...
				WHERE	id='{$id}'";
			mysql_query($SQL) or die(mysql_error());
		}
	}
}

$taskdate1= $_POST['txtReschedule'];
$taskDone = $_POST['chkDone'];
$taskTime=mktime($taskdate1);

// $sql="UPDATE tasks SET completed='1', timeStamp='$taskdate1' where id='$taskid' LIMIT 1;"; $sql="update tasks set completed='1', timeStamp='$taskTime' where id='$taskDone' LIMIT 1;";




mysql_query($sql) or die(mysql_error());


Any help with this would be greatly appreciated! :)

Jason Pruim

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



--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
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