【发布时间】:2016-04-19 11:26:57
【问题描述】:
我正在使用多个 HTML 复选框来提交学生出勤率。复选框一旦单击提交“1”,如果未选中,将提交“0”。选中后我可以提交“1”,但无法提交“0”。以下是我的代码:
<?php
$subcheck = (isset($_POST['subcheck'])) ? 1 : 0;
$date = date("Y/m/d");
foreach ( $student as $attendance ) {
echo "<tr>";
echo "<td>$attendance->id</td>";
echo "<td>$attendance->name</td>";
echo "<td>
$attendance->classroom_id
</td>";?>
<input type="hidden" name="date[]" value="<?php echo $date;?>" />
<td><input type="checkbox" name="status[]" value="<?php echo $attendance->id;?>"></td>
<td><input type="text" name="reason[]" ></td>
<?php
}
?>
<tr>
<td colspan="2" align="center"><input type="submit" value="Save" name="submit"></td>
【问题讨论】: