<!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> <?php include("../Lei.class.php"); $db=new Lei(); $sqlqy="1=1"; //区域判断 if(!empty($_POST["qy"])) { $attrqy=$_POST["qy"]; $quyu=implode("','",$attrqy); $sqlqy=" quyu in ('{$quyu}')"; } $sqlzl="2=2"; if(!empty($_POST["zl"])) { $attrzl=$_POST["zl"]; $zl=implode("','",$attrzl); $sqlzl=" zlleixing in ('{$zl}')"; } $tj=" $sqlqy and $sqlzl"; ?> <form action="fz.php" method="post"> 区域<input type="checkbox" id="qy" onclick="aa()" />全选<br /> <?php $sql="select distinct quyu from house"; //查数据库 输出复选框 $attr=$db->Query($sql); foreach($attr as $v) { $v[0]; echo"<input type='checkbox' class='aa' value='{$v[0]}' name='qy[]'/>{$v[0]}"; } echo"<br />"; ?> 租赁:<input type="checkbox" id="zl" onclick="bb()" />全选<br /> <?php $sqlzl="select distinct zlleixing from house"; //租赁类型 $attrzl=$db->Query($sqlzl); foreach($attrzl as $b) { $b[0]; echo"<input type='checkbox' class='bb' value='{$b[0]}' name='zl[]'/>{$b[0]}"; } ?> <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> </tr> <?php $sql="select * from house where".$tj; $attr=$db->Query($sql); foreach($attr as $v) { echo"<tr> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> <td>{$v[6]}</td> </tr>"; } ?> <script type="text/javascript"> function aa() { var a=document.getElementById("qy").checked; var b=document.getElementsByClassName("qy"); for(var i=0; i<b.length;i++) { b[i].checked = a; } } function bb() { var c=document.getElementById("zl").checked; var d=document.getElementsByClassName("zl"); for(var i=0; i<d.length;i++) { d[i].checked = c; } } </script> </body> </html>