我正在尝试使用复选框更新数据库中所有选定的字段。这是我完成的代码,但是它只会更新我从复选框列表中选择的最后一条记录。
<tbody>
<?php while($row = mysqli_fetch_array($queryEmail)):?>
<tr>
<td><input type="checkbox" name="formDoor[]" value=<?php echo $row['id'];?>>
</td>
<td><?php echo $row['name'];?></td>
<td><?php echo $row['hour'];?></td>
</tr>
<?php endwhile;?>
</tbody>
<?php
$hor = $_POST['hours']; //input value i want to update in selected id's
foreach ($_POST['formDoor'] as $entry){
$sql = "UPDATE hora SET hour='$hor' WHERE id = $entry";
}
?>
答案 0 :(得分:0)
尝试此操作您会忘记在循环上执行mysqli_query()
show:99 Uncaught ReferenceError: iAmOutput is not defined