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>
    
    <body>
    <h1>租房查询</h1>
    <form action="zufangchaxun.php" method="post">
    <div>区域:<input type="checkbox" onclick="CheckAll(this,'qy')"/>全选</div>
    <div>
    <?php
    include("DBDA.class.php");
    $db=new DBDA();
    $sqlqy="select distinct Area from house";//distinct去重
    $attrqy=$db->Query($sqlqy);
    foreach($attrqy as $v)
    {
    	echo "<input class='qy' type='checkbox' value='{$v[0]}' name='qy[]'/>$v[0] ";
    }
    ?>
    </div><br />
    <div>租赁类型:<input type="checkbox" onclick="CheckAll(this,'zllx')"/>全选</div>
    <div>
    <?php
    $sqlzllx="select distinct RentType from house";
    $attrzllx=$db->Query($sqlzllx);
    foreach($attrzllx as $v)
    {
    	echo "<input class='zllx' type='checkbox' value='{$v[0]}' name='zllx[]'/>$v[0] ";
    }
    ?>
    </div><br />
    <div>房屋类型:<input type="checkbox" onclick="CheckAll(this,'fwlx')"/>全选</div>
    <div>
    <?php
    $sqlfwlx="select distinct HouseType from house";
    $attrfwlx=$db->Query($sqlfwlx);
    foreach($attrfwlx as $v)
    {
    	echo "<input class='fwlx' type='checkbox' value='{$v[0]}' name='fwlx[]'/>$v[0] ";
    }
    ?>
    </div><br />
    <div>关键字:<input type="text" name="key"/></div><input type="submit" value="搜索"/>
    </form>
    <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"]))
    	{
    		$str1=implode("','",$_POST["qy"]);
    		$tj1="Area in ('{$str1}')";
    	}
    	if(!empty($_POST["zllx"]))
    	{
    		$str2=implode("','",$_POST["zllx"]);
    		$tj2="RentType in ('{$str2}')";
    	}
    	if(!empty($_POST["fwlx"]))
    	{
    		$str3=implode("','",$_POST["fwlx"]);
    		$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 CheckAll(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>
    

      

  • 相关阅读:
    使用SQLite做本地数据缓存的思考
    毕业后第一次跳槽面试的点滴记录
    Nancy基于JwtBearer认证的使用与实现
    谈谈Nancy中让人又爱又恨的Diagnostics【上篇】
    CentOS 7.x 防火墙开放端口相关用法记录
    浅析如何在Nancy中使用Swagger生成API文档
    浅析如何在Nancy中生成API文档
    初探CSRF在ASP.NET Core中的处理方式
    微信小程序支付简单小结与梳理
    浅析Content Negotation在Nancy的实现和使用
  • 原文地址:https://www.cnblogs.com/hamilton/p/5602956.html
Copyright © 2011-2022 走看看