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