<!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> <style type="text/css"> .qylist { float:left; } .zllist { float:left; } .fwlist { float:left; } </style> </head> <body> <?php include("DBDA.php"); $db = new DBDA(); @$qytj = $_POST["qy"]; @$zltj = $_POST["zl"]; @$fwtj = $_POST["fw"]; @$key = $_POST["key"]; //造查询字符串 $str1 = " 1=1"; $str2 = " 1=1"; $str3 = " 1=1"; $str4 = " 1=1"; //判断第一个条件是否有值 if(count($qytj)>0) { $ss = implode("‘,‘",$qytj); $str1 = " Area in (‘{$ss}‘)"; } //判断租赁类型 if(count($zltj)>0) { $ss = implode("‘,‘",$zltj); $str2 = " RentType in (‘{$ss}‘)"; } //判断房屋类型 if(count($fwtj)>0) { $ss = implode("‘,‘",$fwtj); $str3 = " HouseType in (‘{$ss}‘)"; } //判断关键字 if($key!="") { $str4 = " KeyWord like ‘%{$key}%‘"; } $sqltj = " where".$str1." and".$str2." and".$str3." and".$str4; ?> <form action="0329House.php" method="post"> <div> <div style="margin-top:10px">区域:<input type="checkbox" id="qyall" name="qyall" onclick="CheckAll(this,‘qy‘)" />全选</div> <div> <?php $sqlqy = "select distinct(Area) from HouseDB"; $attrqy = $db->Query($sqlqy); for($i=0;$i<count($attrqy);$i++) { echo "<div class=‘qylist‘> <input type=‘checkbox‘ name=‘qy[]‘ class=‘qy‘ value=‘{$attrqy[$i][0]}‘ /> {$attrqy[$i][0]} </div>"; } ?> </div> <div style="clear:both"></div> <div style="margin-top:20px;">租赁类型:<input type="checkbox" id="zlall" name="zlall" onclick="CheckAll(this,‘zl‘)" />全选</div> <div> <?php $sqlzl = "select distinct(RentType) from HouseDB"; $attrzl = $db->Query($sqlzl); for($i=0;$i<count($attrzl);$i++) { echo "<div class=‘zllist‘> <input type=‘checkbox‘ name=‘zl[]‘ class=‘zl‘ value=‘{$attrzl[$i][0]}‘ /> {$attrzl[$i][0]} </div>"; } ?> </div> <div style="clear:both"></div> <div style="margin-top:20px">房屋类型:<input type="checkbox" id="fwall" name="fwall" onclick="CheckAll(this,‘fw‘)" />全选</div> <div> <?php $sqlfw = "select distinct(HouseType) from HouseDB"; $attrfw = $db->Query($sqlfw); for($i=0;$i<count($attrfw);$i++) { echo "<div class=‘fwlist‘> <input type=‘checkbox‘ name=‘fw[]‘ class=‘fw‘ value=‘{$attrfw[$i][0]}‘ /> {$attrfw[$i][0]} </div>"; } ?> </div> <div style="clear:both"></div> <div style="margin:20px 0px 20px 0px">关键字:<input type="text" name="key" /> <input type="submit" value="搜索" /></div> </div> </form> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>关键字</td> <td>区域</td> <td>面积</td> <td>租金</td> <td>租赁类型</td> <td>房屋类型</td> </tr> <?php $sqlall = "select * from HouseDB".$sqltj; $rall = $db->Query($sqlall); for($i=0;$i<count($rall);$i++) { echo "<tr> <td>{$rall[$i][1]}</td> <td>{$rall[$i][2]}</td> <td>{$rall[$i][3]}</td> <td>{$rall[$i][4]}</td> <td>{$rall[$i][5]}</td> <td>{$rall[$i][6]}</td> </tr>"; } ?> </table> </body> <script type="text/javascript"> function CheckAll(ck,cname) { var all = document.getElementsByClassName(cname); for(var i=0;i<all.length;i++) { all[i].checked = ck.checked; } } </script> </html>
时间: 2024-10-16 23:31:19