I'm trying to update all selected fields in the database using check box. This is the code that I've done, but it only updates the last record I choose from the checkbox list.
<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";
}
?>