<link href= ". /bootstrap.min.css "rel=" stylesheet "type=" Text/css "/><script src=". /bootstrap.min.js "></script><script src=". /jquery-1.11.2.min.js "></script>
<body><form action= "./pldelete.php" method= "POST" ><table class= "Table table-striped" > <caption > Personnel Information Display </caption> <thead> <tr> <th><input type= "checkbox" id= "Ckall"/> codename </th& Gt <th> name </th> <th> gender </th> <th> National </th> <th> birthday </th> <th > Operations </th> </tr> </thead> <tbody> <?php$db = new mysqli ("localhost", "root", "123456", "Cru D "); $sql =" Select Info.code,info.name,sex,nation.name,birthday from Info,nation where Info.nation=nation.code "; $ result = $db->query ($sql), if ($result) {$arr = $result->fetch_all (); foreach ($arr as $v) {$sex = $v [2]? " Male ":" Female ", echo" <tr> <td><input class= ' ck ' type= ' checkbox ' name= ' ck[] ' value= ' {$v [0]} '/>{$v [0]}</t d> <td>{$v [1]}</td> <td>{$sex}</td> <td>{$v [3]}</td> <td> {$v [4]}</td> <td><a href= './delete.php?code={$v [0]} ' onclick=\ ' return confirm (' Confirm delete? ') \ "><button type= ' button ' class= ' btn btn-primary btn-sm ' > Delete </button></a></td> </tr > ";}}? > </tbody></table><div><input type= "Submit" value= "Bulk Delete"/></div></form> <script type= "Text/javascript" >var Ckall = document.getElementById ("Ckall"); Ckall.onclick = function () {var xz = Ckall.checked;var ck = document.getelementsbyclassname ("ck"); for (Var i=0;i<ck.length;i++) {ck[i].checked = XZ;}} </script></body>
Delete Page
<?php$arr = $_post["ck"];//delete from info where code in (' P001 ', ' p002 ', ' p003 ') $str = Implode ("', '", $arr); $sql = "dele Te from info where code in (' {$str} '); $db = new mysqli ("localhost", "root", "123456", "crud"), $result = $db->query ($sql) if ($result) {header ("location:main.php");} Else{echo "Delete failed! ";}
MYSQLI Data Access Bulk Delete