PHP开发企业网站教程之删除新闻资讯
点击删除 跳转到delnews.php 文件
下面我们来看下这个文件的代码:
<?php
//删除新闻资讯部分代码
require_once('conn.php');
$id = $_GET['id'];
$sql = "delete from news where id='$id'";
$res = mysql_query($sql);
if($res){
echo "<script>alert('删除成功');location.href='news.php';</script>";
}else{
echo "<script>alert('删除失败');location.href='news.php';</script>";
}
?>链接数据库,获取表单带过来的参数 id 然后写sql 语句进行删除
执行sql 语句 删除成功,跳转展示页面,这样我们可以在展示页面进行查看
