php出租房数据管理及搜索页面

前端之家收集整理的这篇文章主要介绍了php出租房数据管理及搜索页面前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

PHP数据访问例子:租房信息管理,具体内容如下

1.数据库建表

2. zufangzi.PHP

<div class="jb51code">
<pre class="brush:xhtml;">

租房子

<form action="zufangzi.PHP" method="post">

区域:全选
$sqy = "select distinct area from house";//写SQL语句,并去重
$aqy = $db->query($sqy);
foreach($aqy as $v)
{
echo "{$v[0]}";
}
?>


租赁类型:全选
query($szl); foreach($azl as $v) { echo "{$v[0]}"; } ?>

房屋类型:全选
query($sfw); foreach($afw 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>

所引用的封装类

PHP;"> host,$this->uid,$this->pwd,$this->dbname);
$result = $db->query($<a href="/tag/sql/" target="_blank" class="keywords">sql</a>);

if($type)
{
  //如果是<a href="/tag/chaxun/" target="_blank" class="keywords">查询</a>,<a href="/tag/xianshi/" target="_blank" class="keywords">显示</a>数据
  return $result->fetch_all();
}
else
{
  //如果是增删改,返回true或者false
  return $result;
}

}
}

呈现页面

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

猜你在找的PHP相关文章