类别的删除功能
先给删除标签和全部删除标签都添加一个a标签
<?php <a href="typesave.php?action=del&id=<?php echo $row['id']?>">删除</a> <a href="javascript:delall()">全部删除</a><a href="typeadd.php"> 添加类别</a>
用于获取get请求,然后在typasave.php页面进行处理即可
在typesave.php页面添加以下代码:
elseif ($_GET["action"]=="del"){
$id=$_GET['id'];
$sql = "delete from type where id=$id";
if ($mysqli->query($sql)) {
echo "<script>alert('类别删除成功')</script>";
echo "<script>window.location='typelist.php'</script>";
}
}elseif ($_GET["action"]=="delall"){
$arrid=$_GET["arrid"];
$arr=rtrim($arrid,",");
$sql="delete from type where id in ($arr)";
$result=$mysqli->query($sql);
if($result){
echo "<script>alert('类别删除成功!')</script>";
echo "<script>window.location.href='typelist.php'</script>";
}效果展示:

