類別的刪除功能

先給刪除標籤和全部刪除標籤都新增一個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>";
    }

效果顯示:

gif5新文件 (7).gif


#
繼續學習
||
<?php echo "类别删除功能";
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!