<!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. Oracle 分区表的新增、修改、删除、合并。普通表转分区表方法

    一. 分区表理论知识 Oracle提供了分区技术以支持VLDB(Very Large DataBase).分区表通过对分区列的判断,把分区列不同的记录,放到不同的分区中.分区完全对应用透明. Orac ...

  2. Java常见的几种排序算法-插入、选择、冒泡、快排、堆排等

    本文就是介绍一些常见的排序算法.排序是一个非常常见的应用场景,很多时候,我们需要根据自己需要排序的数据类型,来自定义排序算法,但是,在这里,我们只介绍这些基础排序算法,包括:插入排序.选择排序.冒泡排 ...

  3. django-cms安装

    ubuntu:12.04 (32bit) djangocms 0.5.1 =========================== 首先,跟着这个做: https://github.com/divio/ ...

  4. 深度分析Linux下双网卡绑定七种模式 多网卡的7种bond模式原理

    http://blog.csdn.net/abc_ii/article/details/9991845多网卡的7种bond模式原理 Linux网卡绑定mode共有七种(~) bond0.bond1.b ...

  5. Twisted安装

    Debian sudo apt-get install gcc python-dev && sudo pip install twisted CentOS sudo yum insta ...

  6. PHP无法编译undefined reference to `libiconv_open

    ./configure --prefix=/usr/local/php52 make时提示:.....................................................e ...

  7. docker数据拷贝

    docker数据拷贝的方式有很多种,下面介绍几种数据拷贝的方式:此处只是介绍几种简易的方式,更多方式可以google下. 从容器中向主机拷贝数据 docker cp <containerId&g ...

  8. 64位win系统上面tomcat6启动不了 window不能再本地计算机启动

    64位的jdk装完之后,jre的bin目录下面没有client文件夹, 而tomcat6.0.20的默认配置启动在client文件夹下面. 所以打开tomcat6w,在java选项界面,取消Use d ...

  9. 多线程同步_Monitor

    多线程一直在学习和理解中...... Monitor类是多线程中用以实现同步的一种技术,主要是同一进程内多线程间的同步技术. Monitor类中有以下几个方法需要注意: Monitor.Enter(o ...

  10. 16~25.spring+hibernate简单实例 .连接数据库并进行增删改查

    1.概念 Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQ ...