• PHP 练习:租房子


     1 <form action="text.php" method="post">
     2 区域:<input type="checkbox" id="qy" onclick="CheckAll()"  />全选<br />
     3 <?php
     4 include("../dbda.class.php");
     5 $db = new dbda();
     6 $sql = "select Area from House";
     7 $area = $db->Query($sql);
     8 foreach($area as $v)
     9 {
    10     echo "<input type='checkbox' class='qy' value='{$v[0]}' name='qy[]'/>{$v[0]}";
    11 }
    12 ?>
    13 <br /><br /><br />
    14 租赁类型: <input type="checkbox" id="lx" onclick="LXCheckAll()"   />全选<br />
    15 <?php 
    16 $sql1 = "select distinct RentType from House";
    17 $renttype = $db->Query($sql1);
    18 foreach($renttype as $v)
    19 {
    20     echo "<input type='checkbox' class='lx' value='{$v[0]}' name='lx[]'/>{$v[0]}";
    21 }
    22 ?>
    23 <br /><br /><br />
    24 房屋类型:<input type="checkbox" id="fw" onclick="FWCheckAll()"  />全选<br />
    25 <?php
    26 $sql2 = "select HouseType from House ";
    27 $housetype = $db->Query($sql2);
    28 foreach($housetype as $v)
    29 {
    30     echo "<input type='checkbox' class='fw' value='{$v[0]}' name='fw[]'/>{$v[0]}";
    31 }
    32 ?>
    33 <br /><br /><br />
    34 关键字:<input type="text" name="keyword" /><br />
    35 <br />
    36 <br />
    37 <input type="submit" value="搜索" />
    38 </form>
    39 
    40 
    41 <?php
    42 
    43 
    44 
    45 
    46 $tj1 = " 1=1";
    47 $tj2 = " 1=1";
    48 $tj3 = " 1=1";
    49 $tj4 = " 1=1";
    50 if(!empty($_POST["qy"]))
    51 {
    52     $qy = implode("','",$_POST["qy"]);
    53     $tj1 = " Area in ('{$qy}')";
    54 }
    55 if(!empty($_POST["lx"]))
    56 {
    57     $lx = implode("','",$_POST["lx"]);
    58     $tj2 = " RentType in ('{$lx}')";
    59 }
    60 if(!empty($_POST["fw"]))
    61 {
    62     $fw = implode("','",$_POST["fw"]);
    63     $tj3 = " HouseType in ('{$fw}')";
    64 }
    65 if(!empty($_POST["keyword"]))
    66 {
    67     $tj4 = " KeyWord like '%{$_POST['keyword']}%'";
    68 }
    69 $sqlz = "select * from House where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
    70 $attr = $db->Query($sqlz);
    71 ?>
    72 <table width="100%" border="1" cellpadding="0" cellspacing="0">
    73 <tr><td>关键字</td><td>地区</td><td>面积</td><td>房租</td><td>租赁类型</td><td>房屋类型</td></tr>
    74 <?php
    75 foreach($attr as $v)
    76 {
    77     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>";
    78 }
    79 ?>
    80 </table>

    JS页面

     1 <script type="text/javascript">
     2 function CheckAll()
     3 {
     4     var qx = document.getElementById("qy").checked;
     5     var ch = document.getElementsByClassName("qy");
     6     for(var i=0;i<ch.length;i++)
     7     {
     8         ch[i].checked = qx;
     9     }
    10 }
    11 function LXCheckAll()
    12 {
    13     var qx = document.getElementById("lx").checked;
    14     var ch = document.getElementsByClassName("lx");
    15     for(var i=0;i<ch.length;i++)
    16     {
    17         ch[i].checked = qx;
    18     }
    19 }
    20 function FWCheckAll()
    21 {
    22     var qx = document.getElementById("fw").checked;
    23     var ch = document.getElementsByClassName("fw");
    24     for(var i=0;i<ch.length;i++)
    25     {
    26         ch[i].checked = qx;
    27     }
    28 }
    29 </script>
  • 相关阅读:
    linux 环境变量
    php 守护进程类
    PHP 操作 进程时相关 信号的具体含义
    mongodb 的注意点
    安装了包,pycharm却提示找不到包
    php7下 xhprof安装与使用
    mysql 大数据 查询方面的测试
    mysql 分页测试,
    jmeter 使用
    初步jmeter安装与使用
  • 原文地址:https://www.cnblogs.com/zk0533/p/5475640.html
Copyright © 2020-2023  润新知