1.数据库建表
2. zufangzi.PHP
<div class="jb51code">
<pre class="brush:xhtml;">
租房子
<form action="zufangzi.PHP" method="post">
$aqy = $db->query($sqy);
foreach($aqy as $v)
{
echo "{$v[0]}";
}
?>
<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["qy"]))
{
$aqy = $_POST["qy"];
$sqy = implode("','",$aqy);
$tj1 = " area in ('{$sqy}') ";
}
if(!empty($_POST["zl"]))
{
$azl = $_POST["zl"];
$szl = implode("',$azl);
$tj2 = " renttype in ('{$szl}') ";
}
if(!empty($_POST["fw"]))
{
$afw = $_POST["fw"];
$sfw = implode("',$afw);
$tj3 = " housetype in ('{$sfw}') ";
}
if(!empty($_POST["key"]))
{
$k = $_POST["key"];
$tj4 = " keyword like '%{$k}%' ";
}
$sql = "select * from house where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
echo $sql;
$arr = $db->query($sql);
foreach($arr 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>