<body><?php//Multi-condition $tiaojian2= "2=2"; $attr 2 = "";//Judging region if (!empty ($_post["area])) {$attr 2 = $_post[" Areas "];$ STR2 = Implode ("', '", $attr 2), $tiaojian 2 = "area in (' {$str 2} ')";} Multi-Conditional $tiaojian3= "2=2"; $attr 3 = "";//Determine House type if (!empty ($_post["Renttype")) {$attr 3 = $_post["Renttype"]; $str 3 = Implode ("', '", $attr 3); $tiaojian 3 = "Renttype in (' {$STR 3} ')";} Multi-Conditional $tiaojian4= "2=2"; $attr 4 = "";//determine the lease type if (!empty ($_post["Houesetype"])) {$attr 4 = $_post["Houesetype"]; $STR 4 = Implode ("', '", $attr 4); $tiaojian 4 = "Houesetype in (' {$str 4} ')";}? ><form action= "sousuoyemian.php" method= "post" > <div> area domain: <input type= "checkbox" Onclic K= "Quanxuanqu (This)"/> Select all <?php $tj = "and 1=1"; if (!empty ($_post["GJZ") && $_post["GJZ"]!== "") {$TJ = "and kerword like '%{$_post[' gjz ']}% '";} Include ("fengzhuang.php"); $db = new FENG (); $s = "select * from House"; $a = $db->query ($s);echo "<div>"; foreach ($a as $v) {echo "<input type= ' checkbox ' class= ' Quyu ' value= ' $v [2] ' name= ' area[] ' />{$v [2]} "; } echo "</div>"; ?> </div><br/> <div> House type: <input type= "checkbox" onclick= "Quanxuanfang (This)"/> Select all <?php echo "<div>"; foreach ($a as $v) {echo "<input type= ' checkbox ' class= ' Fangwu ' value= ' $v [5] ' name= ' Rentt ype[] '/>{$v [5]} "; } echo "</div>"; ?> </div><br/> <div> Leasing Type: <input type= "checkbox" onclick= "Quanxuanzu (This)"/> Select all <?php echo "<div>"; foreach ($a as $v) {echo "<input type= ' checkbox ' class= ' Zulin ' value= ' $v [6] ' name= ' Houeset ype[] '/>{$v [6]} "; } echo "</div>"; ?> </DIV><br/> <!--keyword query-<div> off key Word: <input type= "text" name= "GJZ"/></div> <div><input type= "Submit" value= "search"/></div></form> <table style= "width:100%" border= "1" cellpadding= "0" cellspacing= "0" > <tr> <td> keywords </td> <TD&G t; regional </td> <td> floor area </td> <td> rent </td> <td> Lease Type </TD&G T <td> Housing Type </td> </tr> <?php $sql = "SELECT * from house where {$tiaojian 2} and {$tiaojian 3} and {$tiaojian 4} ". $tj; $ar = $db->query ($sql); foreach ($ar as $v) {echo "<tr>"; echo "<td>{$v [1]}</td><td>{$v [2]}</td><td>{$v [3]}</td><td>{$v [4]}< /td><td>{$v [5]}</td><td>{$v [6]}</td> "; echo "</tr>"; }?> </table> <script type= "Text/javascript" > function Quanxuanqu (qu) {//Find all of the check boxes below var c=document.getelementsbyclassname ("Quyu"); Traverse all check boxes to set the selected state for (var i=0; i<c.length; i++) {if (qu.checked) {c[i].setattribute ("checked", "checked"); } else {C[i].removeattribute ("checked"); }}} function Quanxuanfang (Fang) {//Find all of the check boxes below var c=document.getelementsbyclassname ("Fangwu"); Traverse all check boxes to set the selected state for (var i=0; i<c.length; i++) {if (fang.checked) {c[i].setattribute ("checked", "checked"); } else {C[i].removeattribute ("checked"); }}} function Quanxuanzu (zu) {//Find all of the check boxes below var c=document.getelementsbyclassname ("Zulin"); Traverse all check boxes to set the selected state for (var i=0; i<c.length; i++) {if (zu.checked) {c[i].setattribute ("checked", "checked"); } else {C[i].removeattribute ("checked"); }}} </script></body>
Multi-Criteria Query (PHP+MYSQL) Rental House Example