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

php 租房子练习的更多相关文章

  1. 11月6日上午PHP练习《租房子》解析

    一.题目要求 二.题目做法 1.建立数据库 2.封装类文件 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 pu ...

  2. PHP-----练习-------租房子-----增删改查,多条件查询

    练习-------租房子-----增删改查,多条件 一 .题目要求: 二 .做法: [1]建立数据库 [2]封装类文件------DBDA.class.php <?php class DBDA ...

  3. PHP实例练习--投票和租房子

    一,调查问卷 效果图:

  4. php 租房子(练习题)

    一.题目要求 1.功能描述   出租房屋数据管理及搜索页面 2.具体要求 (1) 创建数据库HouseDB,创建表House,要求如下: 二.题目做法 1.建立数据库 2.封装类文件 <?php ...

  5. php封装+租房子练习题

    第一个页面DBDA.class.php <?php class DBDA { public $host = "localhost"; public $uid = " ...

  6. php练习 租房子

    题目要求 1.封装类 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 public $yonghuming=&q ...

  7. 最近要租房子,用Python看一下房源吧..

    前言:最近我的朋友想要租房子,为了装个b,决定运用技术去帮助他. 这个网站是什么我也不知道 反正是一个房子交易网站  http://www.ljia.net/ 设置请求头 headers = {'Ac ...

  8. PHP 练习(租房子)

    一.题目要求 二.题目做法 1.建立数据库 2.封装类文件 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 pu ...

  9. PHP 练习3:租房子

    一.题目要求 二.题目做法 1.建立数据库 2.封装类文件 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 pu ...

  10. 2016/3/30 租房子 ①建立租房子的增、删、改php页面 ②多条件查询 ③全选时 各部分全选中 任意checkbox不选中 全选checkbox不选中

    字符串的另一种写法:<<<AAAA; 后两个AA回车要求顶格  不然报错 例子: <!DOCTYPE html> <html lang="en" ...

随机推荐

  1. HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4902 解题报告:输入一个序列,然后有q次操作,操作有两种,第一种是把区间 (l,r) 变成x,第二种是 ...

  2. BZOJ1452——[JSOI2009]Count

    1.题目大意: 就是给一个n×m的方格,然后一些平面上的 求和 修改操作 2.分析:二维树状数组裸题 #include <cstdio> #include <cstdlib> ...

  3. [codevs1154][COJ0177][NOIP2006]能量项链

    [codevs1154][COJ0177][NOIP2006]能量项链 试题描述 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这 ...

  4. 数据流图DFD画法

    数据流图(DFD- Data Flow Diagram)让系统分析者弄清楚"做什么"的问题,其重要性就不言而喻了.那么我们怎么画数据流图呢?数据流图与系统流程图又有什么区别呢? 步 ...

  5. zabbix之php安装

    转载自: http://www.ttlsa.com/nginx/nginx-php-5_5/ php下载 https://pan.baidu.com/s/1qYGo8bE

  6. Java 重写(Overriding)和重载(Overloading)

    方法的重写(Overriding)和重载(Overloading)是java多态性的不同表现. 重写是父类与子类之间多态性的一种表现 重载是一类中多态性的一种表现.

  7. Maven打包排除不需要的文件。

    pom.xml <!-- package打包排除掉一些配置文件 --> <plugin> <groupId>org.apache.maven.plugins< ...

  8. 一个iOS 框架介绍:MKNetworkKit

    http://blog.csdn.net/kmyhy/article/details/12276287 http://blog.csdn.net/mobailwang/article/details/ ...

  9. C#之基类及接口

    Component类: Component是公共语言运行库中按引用封送的所有组件的基类.Component提供IComponent接口的基实现并启用应用程序之间的对象共享. https://msdn. ...

  10. C++构造函数、析构函数与抛出异常

    [本文链接] http://www.cnblogs.com/hellogiser/p/constructor-destructor-exceptions.html [问题] 构造函数可以抛出异常么?析 ...