Php->msql Multi-Criteria Query

Source: Internet
Author: User

D Multi-Criteria query

BODY&GT;&LT;BR/><form action="duotiaojian.php"Method="Post"><div>Name:<input type="text"Name="XM"/>Nationality Code:<input type="text"Name="MZ"/><input type="Submit"Value="Enquiry"/&GT;&LT;/DIV&GT;&LT;/FORM&GT;&LT;BR/><table width="100%"Border="1"cellpadding="0"cellspacing="0"> <tr> <td> code </td> <td> name </td> <td> sex </td> &lt ;td> nationalities </td> <td> Birthdays </td> <td> actions </td> </tr> <?PHP//first determine if there is a commit value$XXM =""; $TJ="1=1"; $TJ 2="1=1"; if(!empty ($_post["XM"]) && $_post["XM"]!="") {$XXM= $_post["XM"]; $TJ="name like '%{$xxm}% '"; }        if(!empty ($_post["MZ"]) && $_post["MZ"]!="") {$mz= $_post["MZ"]; $TJ 2="nation= ' {$mz} '"; }                //Connecting Objects$db =NewMysqli ("localhost","Root","123","MyDB"); //Write SQL statements$sql ="SELECT * FROM info where". $tj." and". $TJ 2;    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>{$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 (' Are you sure you deleted it? ') \ ' > 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></body>

Php->msql Multi-Criteria Query

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.