我正在尝试使用复选框删除多行,但我似乎没有让它工作。有人可以告诉我我缺少什么或更好的方法吗?
我正在尝试使用它们的 ID 删除行。我收到以下通知,但已yes
删除列中没有设置任何内容
Notice: Array to string conversion in
<form action="" method="post">
<?php
$result = $stmt->get_result();
echo"<div class='message'>";
while ($row = $result->fetch_assoc()) {
?>
<div class='msgwrap'>
<input name="checkbox[<? echo $row['id']?>]" type="checkbox" ><?php echo $row['to_user'];?>
</div>
<?php
}
?>
<input type="submit" name="delete">
</div>
</form>
<?php
if (isset($_POST['delete'])) {
$id = $_POST['checkbox'];
$mydb = new mysqli('localhost', 'root', '', '');
$stmt = $mydb->prepare("update messages SET deleted ='yes' where to_user = ? and id = ? ");
$stmt->bind_param('ss', $user, $id);
$stmt->execute();}
?>