租房子 多条件查询
Posted 于超。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了租房子 多条件查询相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <form action="test.php" method="post"> <div>区域: <input type="checkbox" onclick="CheckAll(this,‘qy‘)" />全选 </div> <div> <?php include("../DBDA.php"); $db = new DBDA(); $sqlqy = "select distinct Area from housedb"; $attrqy = $db->Query($sqlqy); foreach($attrqy as $v) { echo "<input class=‘qy‘ type=‘checkbox‘ value=‘{$v[0]}‘ name=‘qy[]‘ />{$v[0]} "; } ?> </div><br /> <div>租赁类型: <input type="checkbox" onclick="CheckAll(this,‘zl‘)" />全选 </div> <div> <?php $sqlzl = "select distinct RentType from housedb"; $attrzl = $db->Query($sqlzl); foreach($attrzl as $v) { echo "<input class=‘zl‘ type=‘checkbox‘ value=‘{$v[0]}‘ name=‘zl[]‘ />{$v[0]} "; } ?> </div><br /> <div>房屋类型: <input type="checkbox" onclick="CheckAll(this,‘fw‘)" />全选 </div> <div> <?php $sqlfw = "select distinct HouseType from housedb"; $attrfw = $db->Query($sqlfw); foreach($attrfw as $v) { echo "<input class=‘fw‘ type=‘checkbox‘ value=‘{$v[0]}‘ name=‘fw[]‘ />{$v[0]} "; } ?> </div><br /> <div>关键字:<input type="text" name="key" /></div> <br /> <input type="submit" value="搜索" /> </form> <br /> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>关键字</td> <td>区域</td> <td>建筑面积</td> <td>租金</td> <td>租赁类型</td> <td>房屋类型</td> </tr> <?php $tj1 = " 1=1"; $tj2 = " 1=1"; $tj3 = " 1=1"; $tj4 = " 1=1"; if(!empty($_POST["qy"])) { $attr = $_POST["qy"]; $str = implode("‘,‘",$attr); $tj1 = " Area in (‘{$str}‘)"; } if(!empty($_POST["zl"])) { $attr = $_POST["zl"]; $str = implode("‘,‘",$attr); $tj2 = " RentType in (‘{$str}‘)"; } if(!empty($_POST["fw"])) { $attr = $_POST["fw"]; $str = implode("‘,‘",$attr); $tj3 = " HouseType in (‘{$str}‘)"; } if(!empty($_POST["key"])) { $key = $_POST["key"]; $tj4 = " KeyWord like ‘%{$key}%‘"; } $tj = " where {$tj1} and {$tj2} and {$tj3} and {$tj4}"; $sql = "select * from housedb".$tj; $attrall = $db->Query($sql); foreach($attrall as $v) { echo "<tr> <td>{$v[1]}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> <td>{$v[6]}</td> </tr>"; } ?> </table> <script type="text/javascript"> function CheckAll(a,b) { var xz = a.checked;//找到全选的选中状态 var ck = document.getElementsByClassName(b); for(var i=0; i<ck.length;i++) { ck[i].checked = xz; } } </script> </body> </html>
以上是关于租房子 多条件查询的主要内容,如果未能解决你的问题,请参考以下文章
2016/3/30 租房子 ①建立租房子的增删改php页面 ②多条件查询 ③全选时 各部分全选中 任意checkbox不选中 全选checkbox不选中