I cant seem to get my checkbox to update only the checked boxes. Right now when I check any box and click submit, it marks the final row with a value of 1 (even if that row isn't checked). What am I missing here in order to post to the same page and it update any boxes that were checked?
while($row = mysql_fetch_array( $result )) {
$addr = $row['address'];
$info = $row['info'];
$date = $row['date'];
$status = $row['status'];
$id = $row['id'];
?>
<tr>
<td><?php echo $id; ?></td>
<td><?php echo $addr; ?></td>
<td><?php echo $info; ?></td>
<td><?php echo $date; ?></td>
<td><?php echo $status; ?></td>
<td><input type="checkbox" name="handled" value="1"><br></td>
</tr>
<?php
}
?>
</table>
<?php
if (isset($_POST['checked'])) {
echo "Posted!";
$sql2 = "UPDATE requests SET status = 1 WHERE id = '".$id."'";
mysql_query($sql2) or die(mysql_error());
}
?>
<br>
<form action="" method="post">
<input name="checked" type="submit"/>
Aucun commentaire:
Enregistrer un commentaire