Javascript 尝试删除php页面中的多条记录
我正在尝试下面的代码从数据库中删除多个记录。但当我打开users1.php时,我得到了以下结果 users1.php-下面的javascript代码是javscript代码Javascript 尝试删除php页面中的多条记录,javascript,php,Javascript,Php,我正在尝试下面的代码从数据库中删除多个记录。但当我打开users1.php时,我得到了以下结果 users1.php-下面的javascript代码是javscript代码 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> function deleteConfirm()
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
function deleteConfirm(){
var result = confirm("Are you sure to delete users?");
if(result){
return true;
}else{
return false;
}
}
$(document).ready(function(){
$('#select_all').on('click',function(){
if(this.checked){
$('.checkbox').each(function(){
this.checked = true;
});
}else{
$('.checkbox').each(function(){
this.checked = false;
});
}
});
$('.checkbox').on('click',function(){
if($('.checkbox:checked').length == $('.checkbox').length){
$('#select_all').prop('checked',true);
}else{
$('#select_all').prop('checked',false);
}
});
});
</script>
users1.php-php代码-下面是php代码
<?php
include_once('dbcontroller.php');
$query = mysqli_query($conn,"SELECT id, UserName, Type, department FROM Admin_Master";);
?>
<form name="bulk_action_form" action="users2.php" method="post" onsubmit="return deleteConfirm();"/>
<table class="bordered">
<thead>
<tr>
<th><input type="checkbox" name="select_all" id="select_all" value=""/></th>
<th>Username</th>
<th>Type</th>
<th>Department</th>
</tr>
</thead>
<?php
if(mysqli_num_rows($query) > 0){
while($row = mysqli_fetch_assoc($query)){
?>
<tr>
<td align="center"><input type="checkbox" name="checked_id[]" class="checkbox" value="<?php echo $row['id']; ?>"/></td>
<td><?php echo $row['UserName']; ?></td>
<td><?php echo $row['Type']; ?></td>
<td><?php echo $row['department']; ?></td>
</tr>
<?php } }else{ ?>
<tr><td colspan="5">No records found.</td></tr>
<?php } ?>
</table>
<input type="submit" class="btn btn-danger" name="bulk_delete_submit" value="Delete"/>
</form>
如果您需要更多信息,请告诉我 删除mysqli\u查询中的分号
$query=mysqli\u query$conn,从Admin\u Master;中选择id、用户名、类型、部门 检查一下你在做什么:$query=mysqli\u query$conn,$yourquery;如果$结果{dieSQL错误:.mysqli_错误$conn;}@prakashtank抱歉,请检查答案…..有趣;我没有看到从…………中删除的内容,对此表示抱歉,是的,我在几秒钟前收到并发布了答案。。。。。