Multi-Criteria Query (PHP+MYSQL) Rental House Example

Source: Internet
Author: User

<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>"; ?> &LT;/DIV&GT;&LT;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> &LT;TD&G t; regional </td> <td> floor area </td> <td> rent </td> <td> Lease Type &LT;/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" &GT   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

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.