<!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 4791 Alice's Print Service(2013长沙区域赛现场赛A题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4791 解题报告:打印店提供打印纸张服务,需要收取费用,输入格式是s1 p1 s2 p2 s3 p3.. ...

  2. Cocos2d-x 3.2 项目源代码从Mac打包到安卓教程【转自:http://www.2cto.com/kf/201410/342649.html】

    当我们用Xcode写好一个项目的源码之后,如何将它导入到安卓手机中呢?下面我来给大家一步一步讲解: 首先,我们打开终端,cd到Cocos2d-x 3.2文件夹中(注意不是你写的项目文件夹,而是官方项目 ...

  3. 说说JSON和JSONP,也许你会豁然开朗

    前言 由于Sencha Touch 2这种开发模式的特性,基本决定了它原生的数据交互行为几乎只能通过AJAX来实现. 当然了,通过调用强大的PhoneGap插件然后打包,你可以实现100%的Socke ...

  4. ubuntu 安装mysql

    1.检查是否已经安装mysql netstat -tap | grep mysql 2.安装mysql 2.1 先更新下软件列表 :sudo apt-get update 2.2 安装mysql :s ...

  5. u-boot 2011.09 开启debug 调试

    以前做过,现在刚才又想不起来了,这个错误非常的严重. 在这里记一下. debug 调试信息的开启在 include/common.h 有如下宏定义: #ifdef DEBUG #define debu ...

  6. discuzX3后台管理插件开发示例一 用户表查询

    上次的入门已经介绍了后台管理插件开发的基本步骤,下面简单写一个示例查询一下用户表 需要已完成以下操作: 1.已创建test后台管理插件 //详见 http://www.cnblogs.com/savo ...

  7. NET程序内存分析工具CLRProfiler的使用(性能测试)

    http://blog.csdn.net/wy3552128/article/details/8158938 大家都知道.net有一套自己的内存(垃圾)回收机制,除非有一些数据(方法)长期占有内存不随 ...

  8. ubuntu14.04 server安装vncserver

    $ sudo apt-get install -y tightvncserver $ vncserver 转自: https://www.liquidweb.com/kb/how-to-install ...

  9. Oracle 与 entity framework 6 的配置,文档

    官方文档: http://docs.oracle.com/cd/E56485_01/win.121/e55744/intro001.htm#ODPNT123 Oracle 对 微软 实体框架 EF6 ...

  10. vb.net多线程

    Public Class Form1 Dim myThread As Threading.Thread Dim myThread2 As Threading.Thread Private Sub Bu ...