標籤: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) 租房子例子