Brad,
First - Thanks for responding so quickly...
Second - Sorry for two things...
- for primitive coding...
- for not having the whole code. Did not want to flood the message with my code.
My goal is
- to list all the tasks with a comment-box and submit against each...if possible in one form
- but accept comments only for one task when the form is submitted
Here is the complete code I have written that does not work:
<?php
// Open db connection
openDB();
if (isset($POST['submitted']) && !empty($POST[''])) {
//Execute sql
if (isset($_POST['task_id'])) {
$task_id = (int) $_POST['task_id'];
} else {
$task_id = 0;
}
// Escape the task:
// Assumes Magic Quotes are off!
$notes = mysql_real_escape_string($_POST['notes']);
$queryStr = "INSERT INTO task_notes (task_id, notes) VALUES ($task_id, $posting_user_id, $user_id, $notes)";
$resultSet = mysql_query($queryStr);
// Report on the results:
if ($resultSet != true) {
echo '<p>The task could not be added!</p>';
} else {
echo '<p>The task has been added!</p>';
}
$_POST['notes']=null;
}
?>
<?php
print "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=post>\n";
?>
<td class="main"><div class="main1" width=620>
<div class=center>
<div class=center>
<b><i>My tasks</i></b>
</div>
</div>
<?php
// Retrieve all the uncompleted tasks:
$query = 'SELECT task_id, task_details, activity_date FROM tasks WHERE task.status <> 1';
$resultSet = mysql_query($query);
if (!$resultSet) { // add this check.
die('Invalid query: ' . mysql_error());
}
// Also store the tasks in an array for use later:
$posts = array();
while (list($task_id, $task_details,$activity_date) = mysql_fetch_array($resultSet, MYSQLI_NUM)) {
$datetime = strtotime($activity_date);
$date = date('M j', $datetime);
$time = date('g:i a', $datetime);
print "<div class=box3><table width=\"100%\" border=\"0\"><tr><td width=\"90%\">".
"<table width=\"99%\" border=\"0\" ><tr><td>".
$task_details.
"</td></tr><tr><td>It needs to be done on <b>".$date."</b> at <b>".$time."</b></td></tr></table>".
"</td><td width=\"10%\">".
"<table width=\"99%\" border=\"0\"><tr><td>".
"<input type=text name=notes size=10 tabindex=1></input></td></tr>".
"<tr><td>".
"<input name=\"submitted\" type=\"hidden\" value=\"true\" />".
"<input type=submit value=\"Submit\" name=".$task_id."></input></td></tr></table></td></tr></table></div>";
}
?>
</div></td>
</div></td></form>
<?php
closeDB();
?>