HPH-—— >mysql Bulk Delete

Source: Internet
Author: User

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 &LT;/TITLE&GT;&LT;/HEAD&GT;&LT;BODY&GT;&LT;BR/><form action="main.php"Method="Post"><div>Name:<input type="text"Name="XM"/> <input type="Submit"Value="Enquiry"/&GT;&LT;/DIV&GT;&LT;/FORM&GT;&LT;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> &lt ;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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.