I have form inside the while condition in echo because in while condition, some value comes from the database and according to each row, user perform an action in the form.
In the form, the checkbox is onclick of the checkbox, i want the PHP code to be executed in the same page which will update the database.
echo "<tr><td>Assign employee ID</td><td>Task Assign</td><td>Date of Assigning Task</td>
<td>Given Task time</td><td>Time of given task</td><td colspan=3>Read message</td></tr></tr>";
$message=mysql_query("select * from message where receiver_id='$myid' and is_read != 1 ");
while($row=mysql_fetch_array($message))
{
$sender_id=$row["sender_id"];
$receiver_id=$row["receiver_id"];
$task_assign=$row["message"];
$date=$row["date"];
$time_of_given_task=$row["time"];
echo "<tr>
<td>".$sender_id."</td><td>".$receiver_id."</td><td>".$task_assign."</td>
<td>".$date."</td><td>".$time_of_given_task."</td><td>
<form action='message_to_read.php?date=$date&time=$time_of_given_task&receive=$receiver_id' method=post>
<input type=checkbox value=checked name=check onclick=foo();></td>
</form>
</td>
</tr>";
}
echo "</table>";
function foo()
{
$todaydate=$_REQUEST["date"];
echo $todaydate;
$time_of_given_task=$_REQUEST["time"];
echo $time_of_given_task;
$empid=$_REQUEST["receive"];
echo $empid;
$test2=mysql_query("update message set is_read='$update' where receiver_id='$empid' and date='$todaydate' and time='$time_of_given_task' ");
}
onclick=foo()is not going to call the PHPfoofunction... do you have a javascript foo() function? Your checkbox is also not setting a value.