码迷,mamicode.com
首页 > 其他好文 > 详细

租房子

时间:2016-05-25 20:19:07      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

<body>
<form action="zu,php" method="post">
<div>区域:
<input type="checkbox"  onclick="CheckAll(this,‘qy‘)"/>全选</div>
<?php
include("DBDA.class.php");
$db = new DBDA();
$sqlqy = "select distinct Area from house";
$atr = $db->Query($sqlqy,0,"housedb");
foreach($atr as $v)
{
    echo "<input type=‘checkbox‘ class=‘qy‘ value=‘{$v[0]}‘ name=‘qy[]‘/>{$v[0]}
    ";
}
?>
<div><br/></div>
<div>租赁类型:
<input type="checkbox"  onclick="CheckAll(this,‘zl‘)"/>全选</div>
<?php
$sqlzl = "select distinct RentType from house";
$atr = $db->Query($sqlzl,0,"housedb");
foreach($atr as $v)
{
    echo "<input type=‘checkbox‘ class=‘zl‘ value=‘{$v[0]}‘ name=‘zl[]‘/>{$v[0]}
    ";
}
?>
<div><br/></div>
<div>房屋类型:
<input type="checkbox" onclick="CheckAll(this,‘fw‘)"/>全选</div>
<?php
$sqlfw = "select distinct HouseType from house";
$atr = $db->Query($sqlfw,0,"housedb");
foreach($atr as $v)
{
    echo "<input type=‘checkbox‘ class=‘fw‘ value=‘{$v[0]}‘ name=‘fw[]‘/>{$v[0]}
    ";
}
?>
<div><br/></div>
<div>关键字:<input type="text" name="key" /></div>

<input type="submit" value="搜索"/>
</form>
技术分享

 

多条件查询,数据以表格的形式显示;

技术分享
<table width="100%" cellpadding="0" cellspacing="0" border="1">
<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["qy"]))
{
    $str = $_POST["qy"];
    $attr = implode("‘,‘",$str);
    $tj1 = "Area in (‘{$attr}‘)";
}
if(!empty($_POST["zl"]))
{
    $str = $_POST["zl"];
    $attr = implode("‘,‘",$str);
    $tj2 = "RentType in (‘{$attr}‘)";
}
if(!empty($_POST["fw"]))
{
    $str = $_POST["fw"];
    $attr = implode("‘,‘",$str);
    $tj3 = "Housetype in (‘{$attr}‘)";
}
if(!empty($_POST["key"]))
{
    $key = $_POST["key"];
    $tj4 = "keyword like ‘%{$_POST[‘key‘]}%‘";
}
$tj =" where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
$sql = "select * from house".$tj;
$result = $db->Query($sql,0,"housedb");
foreach($result 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>

租房子

标签:

原文地址:http://www.cnblogs.com/dianfu123/p/5528113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!