在index.php中:
<script>
function doDel(id){
if(confirm("确认删除?")){
window.location="action.php?action=del&id"+id;
}
}
</script>
以及
<a href='javascript:void(0);' onclick='doDel({$row['id']})'>删除</a>
在action.php中:
case 'del':
$id = $_GET['id'];
$sql = "delete from stu where id='$id'";
$rw = mysqli_query($conn,$sql);
if ($rw > 0){
echo "<script>alert('删除成功');</script>";
}else{
echo "<script>alert('删除失败');</script>";
}
header('Location: index.php');
break;
id没传过去吧,&id="+id