我在while
条件中有表单,echo
因为在 while 条件中,一些值来自数据库,并且根据每一行,用户在表单中执行一个操作。
在表单中,复选框是onclick
复选框,我希望PHP
代码在同一页面中执行,这将更新数据库。
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' ");
}