多條件查詢(php+mysql) 租房子例子

來源:互聯網
上載者:User

標籤:select   remove   lsp   pre   text   ble   eth   table   cli   

<body><?php//多條件$tiaojian2= " 2=2 ";$attr2 = "";//判斷地區if(!empty($_POST["area"])){$attr2 = $_POST["area"];$str2 = implode("‘,‘",$attr2);$tiaojian2 = "area in(‘{$str2}‘)";}//多條件$tiaojian3= " 2=2 ";$attr3 = "";//判斷房屋類型if(!empty($_POST["renttype"])){$attr3 = $_POST["renttype"];$str3 = implode("‘,‘",$attr3);$tiaojian3 = "renttype in(‘{$str3}‘)";}//多條件$tiaojian4= " 2=2 ";$attr4 = "";//判斷租賃類型if(!empty($_POST["houesetype"])){$attr4 = $_POST["houesetype"];$str4 = implode("‘,‘",$attr4);$tiaojian4 = "houesetype in(‘{$str4}‘)";}?><form action="sousuoyemian.php" method="post">        <div>區  域:<input type="checkbox" onclick="quanxuanqu(this)"/>全選       <?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>房屋類型:<input type="checkbox" onclick="quanxuanfang(this)"/>全選      <?php                   echo"<div>";               foreach($a as $v)               {                 echo"<input type=‘checkbox‘  class=‘fangwu‘ value=‘$v[5]‘ name=‘renttype[]‘/>{$v[5]}";               }               echo"</div>";    ?>    </div><br />        <div>租賃類型:<input type="checkbox" onclick="quanxuanzu(this)"/>全選      <?php               echo"<div>";               foreach($a as $v)               {                 echo"<input type=‘checkbox‘ class=‘zulin‘ value=‘$v[6]‘ name=‘houesetype[]‘/>{$v[6]}";               }               echo"</div>";    ?>    </div><br />        <!-- 關鍵字查詢 -->    <div>關 鍵 字:<input type="text" name="gjz"/></div>    <div><input type="submit" value="搜尋" /></div></form>   <table style="width:100%" border="1" cellpadding="0" cellspacing="0">         <tr>                        <td>關鍵字</td>            <td>地區</td>            <td>使用面積</td>            <td>租金</td>            <td>租賃類型</td>            <td>房屋類型</td>         </tr>             <?php      $sql="select * from house where  {$tiaojian2} and  {$tiaojian3} and {$tiaojian4} ".$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)   {   //找到下面所有的複選框   var  c=document.getElementsByClassName("quyu");   //遍曆所有複選框,設定選中狀態   for (var i=0; i<c.length; i++)   {   if(qu.checked)   { c[i].setAttribute("checked","checked");   }   else    { c[i].removeAttribute("checked");      }      }      } function  quanxuanfang(fang)   {   //找到下面所有的複選框   var  c=document.getElementsByClassName("fangwu");   //遍曆所有複選框,設定選中狀態   for (var i=0; i<c.length; i++)   {   if(fang.checked)   { c[i].setAttribute("checked","checked");   }   else    { c[i].removeAttribute("checked");      }      }      } function  quanxuanzu(zu)   {   //找到下面所有的複選框   var  c=document.getElementsByClassName("zulin");   //遍曆所有複選框,設定選中狀態   for (var i=0; i<c.length; i++)   {   if(zu.checked)   { c[i].setAttribute("checked","checked");   }   else    { c[i].removeAttribute("checked");      }      }      }  </script></body>

  

多條件查詢(php+mysql) 租房子例子

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.