我想从mysql数据库中删除多行使用php代码这个我的代码但我有这个消息错误如何解决这个问题?从mysql数据库删除多行
您的SQL语法错误;检查手册中 对应于你的MySQL服务器版本正确的语法使用 “开”在附近的1号线
$files_query=mysqli_query($conn,"select * from tbl_files where db_isdeleted='1'")or die(mysqli_error($conn));
if(mysqli_num_rows($files_query)>0){
echo"<table class='table table-hover table-responsive table-bordered'><tr>";
echo"<td style='background:#f7ac01;font-size:16px;text-align: center;'><input type='checkbox' class='allcb' data-child='chk'/></td>
<td style='background:#f7ac01;font-size:16px;text-align: center;'>FileName</td>
<td style='background:#f7ac01;font-size:16px;text-align: center;'>Date</td>";
echo"</tr>";
while($row=mysqli_fetch_array($files_query)){
$id=$row['db_id'];
$name=$row['name'];
$date=$row['db_date'];
echo"<tr>";
echo'<form method="post" action="">';
echo"<input type='hidden' name='txt_table' value='tbl_files'>";
echo"<input type='hidden' name='txt_action' value='files'>";
echo"<td style='text-align: center;'><input type='checkbox' name='item[]' class='chk'/></td>";
echo"<td style='text-align: center;'>$name</td>";
echo"<td style='text-align: center;'>$date</td>";
}
echo"</tr>";
echo"</table>";
echo"<input type='submit' name='delete' value='Delete' class='btn btn-danger'> ";
echo"<input type='submit' name='restore' value='Restore' class='btn btn-success'>";
echo"</form>";
}
/*************** *********
<?php
if(isset($_POST['delete'])){
$table=$_POST['txt_table'];
$action=$_POST['txt_action'];
foreach($_REQUEST['item'] as $id) {
// delete the item with the id $id
$delete_query=mysqli_query($conn,"DELETE FROM {$table} WHERE db_id=$id")or die(mysqli_error($conn));
header("location:recyclebin.php?action=$action&msg=1");
}
}
?>
你能在这里呼应查询? – Jigar7521
在你的代码中没有工作'on'..确保这段代码是正确的 – scaisEdge
这不好,你有一个SQL注入问题,你打开你的窗体在循环但关闭它的循环(和表...)。在一个地方,你甚至不能使用表单或表单域... – jeroen