创建
我们在index.php 页面做了删除链接
删除
还使用了JS的警告框做了删除确认
function doDel(id) {
if(confirm('确认删除?')) {
window.location='action.php?action=del&id='+id;
}
}
删除信息
链接数据库,删除从删除页面传过来的相关的ID信息
代码如下<?php
header("content-type:text/html;charset=utf8");
$id = $_GET['id'];
$conn=mysqli_connect("localhost","root","root","study");
mysqli_set_charset($conn,"utf8");
$sql = "delete from stu where id='$id'";
$rw = mysqli_query($conn,$sql);
if ($rw > 0){
echo "";
}else{
echo "";
}
header('Location: index.php');
?>
这样,就完成了我们的删除功能,我们将我们前面的所有代码简化融合一下