Bulk Delete
va<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">"http://www.w3.org/1999/xhtml">"Content-type"Content="text/html; Charset=utf-8"/><title> Untitled document </TITLE></HEAD><BODY><BR/><form action="main.php"Method="Post"><div>Name:<input type="text"Name="XM"/> <input type="Submit"Value="Enquiry"/></DIV></FORM><BR/><form action="piliangshanchu.php"Method="Post"><table width="100%"Border="1"cellpadding="0"cellspacing="0"> <tr> <td><input type="checkbox"onclick="Quanxuan (This)"/> code </td> <td> name </td> <td> gender </td> <td> National </td> < ;td> Birthdays </td> <td> actions </td> </tr> <?PHP//first determine if there is a commit value$XXM =""; $TJ="1=1"; if(!empty ($_post["XM"]) && $_post["XM"]!="") {$XXM= $_post["XM"]; $TJ="name like '%{$xxm}% '"; } //Connecting Objects$db =NewMysqli ("localhost","Root","123","MyDB"); //Write SQL statements$sql ="SELECT * FROM info where". $tj; Echo $sql; //Execute SQL statement$result = $dbquery ($sql); //Read Data$attr = $resultFetch_all (); foreach($attr as$v) {echo"<tr>"; $sex= $v [2]?"male":"female"; //Query name family name based on name Family Code$name = Nationname ($v [3]); //Replace keyword$newname = Str_replace ($XXM,"<mark>{$xxm}</mark>", $v [1]); Echo"<td><input type= ' checkbox ' value= ' {$v [0]} ' name= ' sc[] ' class= ' qx '/>{$v [0]}</td><td>{$ newname}</td><td>{$sex}</td><td>{$name}</td><td>{$v [4]}</td><td ><a href= ' shanchu.php?c={$v [0]} ' onclick=\ ' return confirm (' OK to delete? ') \ ' > Delete </a><a href= ' xiugai.php?c={$v [0]} ' > Modify </a></td>"; /*foreach ($v as $v 1) {echo "<td>{$v 1}</td>"; }*/Echo"</tr>"; } //give a national code, return the name of the Nationfunction Nationname ($code) {//Connecting Objects$db =NewMysqli ("localhost","Root","123","MyDB"); //Write SQL statements$sql ="select name from Nation where code= ' {$code} '"; //Execute SQL statement$result = $dbquery ($sql); $attr= $resultFetch_row (); return$attr [0]; } ?> </table><a href="add.php"><input type="Button"Value="Add Data"/></a><input type="Submit"Value="Bulk Delete"onclick="return confirm (' OK delete ')"/></form><script type="Text/javascript">function Quanxuan (a) {//Find all of the check boxes below varCK =document.getelementsbyclassname ("QX"); //Traverse all check boxes to set the selected state for(varI=0; i<ck.length;i++) { if(A.checked) {Ck[i].setattribute ("checked","checked"); } Else{Ck[i].removeattribute ("checked"); } } }</script></body>Bulk Delete processing <?php$attr=Array ();if(!empty ($_post["SC"]) {$attr= $_post["SC"];} $db=NewMysqli ("localhost","Root","123","MyDB");/*foreach ($attr as $v) {$sql = "Delete from info where code= ' {$v} '"; $db->query ($sql);}*/$str= Implode ("', '", $attr);//echo $str;$sql="Delete from info where code in (' {$str} ')"; $db-query ($sql);//Delete from info where code in (' P001 ', ' p002 ', ' p003 ')
HPH-—— >mysql Bulk Delete