PHP开发 留言板教程之留言板删除留言PHP页面
删除留言其实就是删除我们数据库里的数据
我们前面在删除链接之前传入了每条数据的 id
<td><a href="ressage_delete.php?id=<?php echo $row['id']?>" >删除</a> </td>
所以在PHP页面接收id,然后在删除相关的id,就可以实现删除的功能了

代码如下
<?php
header("content-type:text/html;charset=utf-8");
$conn=mysqli_connect("localhost","root","root","ressage");
$id=$_GET['id'];
if($conn){
$sql="delete from ressage_user where id ='$id' ";
$que=mysqli_query($conn,$sql);
if($que){
echo"<script>alert('删除成功,返回首页');location.href='ressage.php';</script>";
}else{
echo "<script>alert('删除失败');location='" . $_SERVER['HTTP_REFERER'] . "'</script>";
exit;
}
}die("数据库连接失败" .mysqli_connect_error());
?>
