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>
    

      

  • 相关阅读:
    网络摄像头Androi端显示(mjpeg)源码分析
    STM32F103 MQTT智能配网ESP07S WIFI 手机app控制继电器EMQ温湿度
    安装云服务器 ECS CentOS 7 图形化桌面
    PT100多路分布式LORA无线测温传感器工业设备老化温度监控记录仪
    把qt 程序打包成一个exe可以执行的文件
    STM32L051C8T6 HAL DMA IDLE串口不定长接收遇到的问题
    Project ERROR: Cannot run target compiler '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++'. Output:
    更换下平台
    H5单页面应用(SPA)架构总结
    财务系统功能开发要点概述
  • 原文地址:https://www.cnblogs.com/hamilton/p/5602956.html
Copyright © 2011-2022 走看看