[英]How to update selected checkbox values in php mysql?
In html table selected checkbox when submit, update selected checkbox values to mysql database提交时在 html 表选中复选框中,将选中的复选框值更新到 mysql 数据库
example : update enquires set status = '2' where id in ( selected checkbox values)
示例:
update enquires set status = '2' where id in ( selected checkbox values)
Use the name attr of checkbox as array like 'id[]'使用复选框的名称 attr 作为数组,如 'id[]'
like.喜欢。
<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>
After submit the form you will get all the checked id in array.提交表单后,您将获得数组中所有已检查的 id。 using implode get the id separated by comma and use in update query.
使用 implode 获取以逗号分隔的 id 并在更新查询中使用。
like.喜欢。
<?php
if(isset($_POST['update_data'])){
echo $query_id = implode(',', $_POST['id']);
//write the update query
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.