Category delete function

First add an a tag to both the delete tag and all delete tags

<?php
<a href="typesave.php?action=del&id=<?php echo $row['id']?>">删除</a>
<a href="javascript:delall()">全部删除</a><a href="typeadd.php"> 添加类别</a>


## Used to obtain get requests, and then process it on the typasave.php page

Add the following code to the typesave.php page:

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>";
    }

Effect display:

gif5新文件 (7).gif


Continuing Learning
||
<?php echo "类别删除功能";
submitReset Code