• 找房子(数据库应用)


    <!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>

    <h1>租房子</h1>

    <form action="zufangzi.php" method="post">
    <div>区域:<input type="checkbox" name="qx" onclick="quanxuan(this,'qy')" />全选</div>
    <div>
    <?php
    require "../0428/DBDA.class.php";
    $db = new DBDA();

    $sqy = "select distinct area from housedb";
    $aqy = $db->query($sqy);
    foreach($aqy as $v)
    {
        echo "<input type='checkbox' name='qy[]' value='{$v[0]}' class='qy' />{$v[0]}";
    }
    ?>
    </div>
    <br />

    <div>租赁类型:<input type="checkbox" name="zlqx" onclick="quanxuan(this,'zl')" />全选</div>
    <div>
    <?php
    $szl = "select distinct renttype from housedb";
    $azl = $db->query($szl);
    foreach($azl as $v)
    {
        echo "<input type='checkbox' name='zl[]' value='{$v[0]}' class='zl' />{$v[0]}";
    }
    ?>
    </div>
    <br />
    <div>房屋类型:<input type="checkbox" name="fwqx" onclick="quanxuan(this,'fw')" />全选</div>
    <div>
    <?php
    $sfw = "select distinct housetype from housedb";
    $afw = $db->query($sfw);
    foreach($afw as $v)
    {
        echo "<input type='checkbox' name='fw[]' value='{$v[0]}' class='fw' />{$v[0]}";
    }
    ?>
    </div>
    <br />
    <div>关键字:<input type="text" name="key" /> <input type="submit" value="查询" /></div>
    </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"]))
        {
            $aqy = $_POST["qy"];
            $sqy = implode("','",$aqy);
            
            $tj1 = " area in ('{$sqy}') ";
        }
        
        if(!empty($_POST["zl"]))
        {
            $azl = $_POST["zl"];
            $szl = implode("','",$azl);
            
            $tj2 = " renttype in ('{$szl}') ";
        }
        
        if(!empty($_POST["fw"]))
        {
            $afw = $_POST["fw"];
            $sfw = implode("','",$afw);
            
            $tj3 = " housetype in ('{$sfw}') ";
        }
        
        if(!empty($_POST["key"]))
        {
            $k = $_POST["key"];
            $tj4 = " keyword like '%{$k}%' ";
        }
        
        
        $sql = "select * from housedb where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
        echo $sql;
        
        $arr = $db->query($sql);
        foreach($arr 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>

    </body>
    <script type="text/javascript">
    function quanxuan(qx,a)
    {
        //找到该全选按钮对应的checkbox列表
        var ck = document.getElementsByClassName(a);
        //找全选按钮选中状态
        if(qx.checked)
        {
            for(var i=0;i<ck.length;i++)
            {
                ck[i].setAttribute("checked","checked");
            }
        }
        else
        {
            for(var i=0;i<ck.length;i++)
            {
                ck[i].removeAttribute("checked");
            }
        }
        
    }
    </script>
    </html>

  • 相关阅读:
    七月二十二日学习报告
    七月二十一学习报告
    七月二十学习报告
    补 七月十九学习报告
    七月十八学习报告
    iOS 逆向工程(三)之Xcode检测是否越狱成功
    iOS 逆向工程(二)之越狱手机安装必备软件
    iOS逆向工程(一)之手机越狱
    html练习 简单html页面
    集合对象序列化 反序列 IO 1将文件中的所有信息,通过合适的IO流读取出来,封装成Person对象,使用集合进行存储 2将集合对象序列化到另外一个文件persons.txt中 3从persons.txt反序列化其中的集合,并遍历集合内容
  • 原文地址:https://www.cnblogs.com/zhangbaobao/p/6807030.html
Copyright © 2020-2023  润新知