[英]How to update selected checkbox values in php mysql?
使用复选框的名称 attr 作为数组,如 'id[]'
喜欢。
<form method="post">
<table>
<tr>
<td><input type="checkbox" value="<?php echo $row_id;?>" name="id[]"></td>
<!-- other table data <td> -->
</tr>
<tr>
<td><input type="checkbox" value="<?php echo $row_id;?>" name="id[]"></td>
<!-- other table data <td> -->
</tr>
</table>
<input type="submit" name="update_data" value="update">
</form>
提交表单后,您将获得数组中所有已检查的 id。 使用 implode 获取以逗号分隔的 id 并在更新查询中使用。
喜欢。
<?php
if(isset($_POST['update_data'])){
echo $query_id = implode(',', $_POST['id']);
//write the update query
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.