php数据访问例子:租房信息管理,具体内容如下
1.数据库建表
2. zufangzi.php
租房子
require "DBDA.class1.php";
$db = new DBDA();
$sqy = "select distinct area from house";//写SQL语句,并去重
$aqy = $db->query($sqy);
foreach($aqy as $v)
{
echo "{$v[0]}";
}
?>
$szl = "select distinct renttype from house";
$azl = $db->query($szl);
foreach($azl as $v)
{
echo "{$v[0]}";
}
?>
$sfw = "select distinct housetype from house";
$afw = $db->query($sfw);
foreach($afw as $v)
{
echo "{$v[0]}";
}
?>
关键字 | 区域 | 建筑面积 | 租金 | 租赁类型 | 房屋类型 |
$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 "
{$v[1]}{$v[2]}{$v[3]}{$v[4]}{$v[5]}{$v[6]}";}
?>
function quanxuan(qx,a)
{
//找到该全选按钮对应的checkbox列表
var ck = document.getElementsByClassName(a);
//找全选按钮选中状态
if(qx.checked)
{
for(var i=0;i
{
ck[i].setAttribute("checked","checked");
}
}
else
{
for(var i=0;i
{
ck[i].removeAttribute("checked");
}
}
}