zoukankan      html  css  js  c++  java
  • 租房子

    <body>
    <form action="zu,php" method="post">
    <div>区域:
    <input type="checkbox"  onclick="CheckAll(this,'qy')"/>全选</div>
    <?php
    include("DBDA.class.php");
    $db = new DBDA();
    $sqlqy = "select distinct Area from house";
    $atr = $db->Query($sqlqy,0,"housedb");
    foreach($atr as $v)
    {
        echo "<input type='checkbox' class='qy' value='{$v[0]}' name='qy[]'/>{$v[0]}
        ";
    }
    ?>
    <div><br/></div>
    <div>租赁类型:
    <input type="checkbox"  onclick="CheckAll(this,'zl')"/>全选</div>
    <?php
    $sqlzl = "select distinct RentType from house";
    $atr = $db->Query($sqlzl,0,"housedb");
    foreach($atr as $v)
    {
        echo "<input type='checkbox' class='zl' value='{$v[0]}' name='zl[]'/>{$v[0]}
        ";
    }
    ?>
    <div><br/></div>
    <div>房屋类型:
    <input type="checkbox" onclick="CheckAll(this,'fw')"/>全选</div>
    <?php
    $sqlfw = "select distinct HouseType from house";
    $atr = $db->Query($sqlfw,0,"housedb");
    foreach($atr as $v)
    {
        echo "<input type='checkbox' class='fw' value='{$v[0]}' name='fw[]'/>{$v[0]}
        ";
    }
    ?>
    <div><br/></div>
    <div>关键字:<input type="text" name="key" /></div>
    
    <input type="submit" value="搜索"/>
    </form>
    复制代码

    多条件查询,数据以表格的形式显示;

    复制代码
    <table width="100%" cellpadding="0" cellspacing="0" border="1">
    <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"]))
    {
        $str = $_POST["qy"];
        $attr = implode("','",$str);
        $tj1 = "Area in ('{$attr}')";
    }
    if(!empty($_POST["zl"]))
    {
        $str = $_POST["zl"];
        $attr = implode("','",$str);
        $tj2 = "RentType in ('{$attr}')";
    }
    if(!empty($_POST["fw"]))
    {
        $str = $_POST["fw"];
        $attr = implode("','",$str);
        $tj3 = "Housetype in ('{$attr}')";
    }
    if(!empty($_POST["key"]))
    {
        $key = $_POST["key"];
        $tj4 = "keyword like '%{$_POST['key']}%'";
    }
    $tj =" where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
    $sql = "select * from house".$tj;
    $result = $db->Query($sql,0,"housedb");
    foreach($result 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>
  • 相关阅读:
    JQuery替换空字符串和正则表达式校验时间格式
    数据库升级,给某张表增加字段,防止重复升级时sql脚本报错
    将jar包安装到本地repository中
    springCloud集成常用组件(持续更新)
    记一次springboot配置事务@transactional失效的事故
    分布式锁实现(Redis和zookeeper)
    springCloud集成zookeper
    zookeeper学习相关
    springboot集成activeMq
    springboot集成redis
  • 原文地址:https://www.cnblogs.com/dianfu123/p/5528113.html
Copyright © 2011-2022 走看看