我有一张没有用户的桌子
$listuser = mysql_query('SELECT id,firstname,lastname,approve FROM user');
echo '<form action="" method="post">';
echo '<table>
<tr><td>Name</td>
<td>AdminApprove</td>
</tr>';
while($row = mysql_fetch_assoc($listuser))
{
$id = $row['id'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
echo '<tr>
<td><input type="hidden" name="id[]" value ='.$id.'></td>
<td>'.$firstname.''.$lastname.'</td>
<td><input type="checkbox" name="approve[]"></td>
</tr>';
}
echo '<tr><td><input type="submit" name="submit" value="submit"></td></tr>';
echo '</table></form>';
提交表格后
$postedid = $_POST['id'];
$approve = isset($_POST['approve']) ? 1 : 0;
$approvestudent = 'UPDATE user SET approve = '.$approve.' WHERE id = '.$postedid.'';
$result_update = mysql_query($approvestudent);
我想为每个学生一次批准一个或多个,并且批准的复选框值需要使用 0 或 1 存储到数据库中