zoukankan      html  css  js  c++  java
  • php 租房子练习

    <!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>
    <?php
    include("dbda.class.php");
    $db=new dbda();
    
    //查询区域
    $sqy="select distinct area from house";
    $aqy=$db->Query($sqy);
    //查询租赁类型
    $slx="select distinct renttype from house";
    $alx=$db->Query($slx);
    //查询房屋类型
    $sfw="select distinct housetype from house";
    $afw=$db->Query($sfw);
    
    ?>
    
    <body>
    <form action="zufang.php" method="post">
    <h1>查询界面</h1>
    <div>区域:<input type="checkbox" id="qyqx" 
    onclick="quanxuan(this,'qy')" />全选</div>
    <div>
    <?php
    foreach($aqy as $v)
    {
        echo "<input class='qy' name='qy[]' type='checkbox' 
        value='{$v[0]}' />{$v[0]}&nbsp;";    
    }
    ?>
    </div><br />
    
    <div>租赁类型:<input type="checkbox" id="lxqx" 
    onclick="quanxuan(this,'lx')" />全选</div>
    <div>
    <?php
    foreach($alx as $v)
    {
        echo "<input class='lx' name='lx[]' type='checkbox' 
        value='{$v[0]}' />{$v[0]}&nbsp;";    
        }
    ?>
    </div><br />
    
    <div>房屋类型:<input type="checkbox" id="fwqx" 
    onclick="quanxuan(this,'fw')" />全选</div>
    <div>
    <?php
    foreach($afw as $v)
    {
        echo "<input class='fw' name='fw[]' type='checkbox' 
        value='{$v[0]}' />{$v[0]}&nbsp;";    
        }
    ?>
    </div><br />
    
    <div>关键字:<input type="text" name="key" /></div><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>
            <td>房屋类型</td>
        </tr>
        <?php
        
        //接受查询条件并处理
        $tj1=" 1=1";
        $tj2=" 1=1";
        $tj3=" 1=1";
        $tj4=" 1=1";
        
        if(!empty($_POST))
        {
            if(!empty($_POST["qy"]))
            {
                //area in ('aa','bb','cc')
                $str1=implode("','",$_POST["qy"]);
                $tj1="area in ('{$str1}')";    
            }    
            if(!empty($_POST["lx"]))
            {
                $str2=implode("','",$_POST["lx"]);
                $tj2="renttype in ('{$str2}')";        
            }
            if(!empty($_POST["fw"]))
            {
                $str3=implode("','",$_POST["fw"]);
                $tj3="housetype in ('{$str3}')";        
            }
            if($_POST["key"]!="")
            {
                $tj4="keyword like '%{$_POST['key']}%'";    
            }
        }
        //查询总条件
        $ztj=" where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
        
        $sql="select * from house".$ztj;
        
        echo $sql;
        
        $attr=$db->Query($sql);
        
        foreach($attr 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(a,b)
    {
        var ck=document.getElementsByClassName(b);
        
        for(var i=0;i<ck.length;i++)
        {
            if(a.checked)
            {
                ck[i].setAttribute("checked","checked");    
            }
            else
            {
                ck[i].removeAttribute("checked");    
            }
        }
    }
    </script>
    </html>
    View Code
  • 相关阅读:
    内存溢出和内存泄漏的区别、产生原因以及解决方案
    HTTP1.0、HTTP1.1 和 HTTP2.0 的区别
    TCP, UDP, HTTP, HTTPS协议
    测试面试常见面试题汇总
    SDK测试方法
    App弱网测试工具--Qnet
    PerfDog性能狗移动端性能测试工具
    Jmeter作用域
    事务(转账功能)
    DBUtils
  • 原文地址:https://www.cnblogs.com/bilibiliganbei/p/5597762.html
Copyright © 2011-2022 走看看