<!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. MySQL中的运算符

    一.算法运算符: (A) 除法运算和模运算中,如果除数为0,非法,返回结果为NULL. 二.比较运算符: (A) 比较结果不确定是返回NULL. (B) 比较运算符可以用于比较数字.字符串和表达式.数 ...

  2. CSS继承总结

    CSS的一个重要特征就是继承,它是依赖于祖先-后代的关系的.继承是一种机制,它允许样式不仅可以应用于某个特定的元素,还可以应用于它的后代. CSS可以继承的属性有: 1.文字相关:font-famil ...

  3. 引擎崩溃、异常、警告、BUG与提示总结及解决方法

    http://www.58player.com/blog-635-128.html [Unity3D]引擎崩溃.异常.警告.BUG与提示总结及解决方法   此贴会持续更新,都是项目中常会遇到的问题,总 ...

  4. 读书笔记-JVM

    局部变量表(虚拟机栈中的一部分)在编译期完成分配,运行期不会再改变大小: 每个方法对应一个栈帧(存储局部变量表.操作数栈.动态链接.方法出口等),栈帧被存储到虚拟机栈中,每个线程对应一个虚拟机栈,方法 ...

  5. python的变量作用域问题

    偶然掉进了一个坑里.仔细分析了下原因.原来是变量作用域的问题.简单抽象如下: id=1 #许多行代码 [id for id in range(10)] #许多行代码 if id!=1: #做一些事情 ...

  6. Python 列表元素排重uniq

    # -*- coding: gbk -*- def uniq(ls): lsCopy=[e for e in ls] for i in xrange(1,len(ls)): for j in xran ...

  7. HTTP Servlet 重要的几个方法

    HTTP Servlet继承了GencenServlet类    GencenServlet实现了两个接口··一个用于ServletConfig设置接口,一个为Servlet接口只要是(1) init ...

  8. Silverlight 中datagrid控件-- 通过设置数据虚拟化加速显示

    定义依赖属性作为datagrid的数据源 protected static readonly DependencyProperty ViewLogsProperty = DependencyPrope ...

  9. Unity3d运行时动态修改材质

    void Start () { const string MainTexVariableName = "_MainTex"; var renders = gameObject.Ge ...

  10. 事件查看器事件ID部分说明

    事件查看器从简单的查看电脑登录信息到检查系统是否出现错误,是否被入侵都有着很重要的作用,Microsoft为了简便,采用事件ID来代表一些信息,下面是我从Microsoft找来的WIN2003的对应关 ...