代码如下:
<!DOCTYPE html>
<html>
<head>
<title>租屋子</title>
<script src=\公众bootstrap/js/jquery-1.11.2.min.js\公众></script> //引入bootstrap前端框架的三个文件
<script src=\公众bootstrap/js/bootstrap.min.js\"大众></script>
<link href=\"大众bootstrap/css/bootstrap.min.css\公众 rel=\公众stylesheet\"大众 type=\"大众text/css\"大众/>
</head>
<style>
.yangshi{
margin-left: 69px;
}
.ys{
margin-left: 69px;
}
.juli{
margin-left: 28px;
}
</style>
<body>
<form action=\"大众rental.php\"大众 method=\"大众get\"大众 style=\"大众margin-top: -145px;\"大众> //form表单中利用get办法进行提交
<div style=\"大众width: 80%; height: 650px; background-image: url(./img/魅力罗兰Music炫图13.jpg); margin-left: 150px; margin-top: 150px;\"大众>
<div style=\"大众margin-left: 20px;\"大众>
<h1 style=\"大众margin-left: 40%; pading-top: 20px;\"大众>租屋子</h1>
<div class=\"大众juli\公众>区域:<input type=\"大众checkbox\公众 class=\"大众ck1\"大众 onclick=\"大众qx(this)\公众> 全选</div>
<div>
//连接数据库并利用去重查询取出列名为区域的这一组数据
<?php
require_once \公众./DBDA.class.php\公众;
require_once \公众./page.class.php\"大众;
$db = new DBDA();
$sqy = \"大众select distinct area from housedb\"大众; //去重查询
$aqy =$db->query($sqy,0);
foreach($aqy as $v){
echo \"大众<span class='c24ca99f0ff50f44 yangshi'><input type='checkbox' class='a99f0ff50f44ff1c ck1' name='qy[]' value='{$v[0]}'> {$v[0]}</span>\"大众;
}
?>
</div>
</div>
效果如图:
<div style=\"大众margin-left: 20px; margin-top: 20px;\公众>
<div>租房类型:<input type=\公众checkbox\"大众 class=\"大众ck2\"大众 onclick=\公众zflx(this)\"大众> 全选</div>
<div>
//连接数据库并利用去重查询取出列名为租房类型的这一组数据
<?php
$srt = \"大众select distinct renttype from housedb\公众;
$art = $db->query($srt,0);
foreach($art as $v){
echo \公众<span class='0ff50f44ff1c74dd ys'><input type='checkbox' class='0f44ff1c74dd9e36 ck2' name='zflx[]' value='{$v[0]}'> {$v[0]}</span>\"大众;
}
?>
</div>
效果如图:
<div style=\"大众margin-top: 20px;\"大众>
<div class=\公众juli\"大众>户型:<input type=\"大众checkbox\"大众 class=\"大众ck3\"大众 onclick=\公众hx(this)\"大众> 全选</div>
<div>
//连接数据库并利用去重查询取出列名为户型的这一组数据
<?php
$sht = \"大众select distinct housetype from housedb\"大众;
$aht = $db->query($sht,0);
foreach($aht as $v){
echo \"大众<span class='ff1c74dd9e36f206 yangshi'><input type='checkbox' class='74dd9e36f2067d95 ck3' name='hx[]' value='{$v[0]}' > {$v[0]}</span>\"大众;
}
?>
</div>
</div>
效果如图:
</div>
<div style=\"大众margin-top: 20px; margin-left: 20px;\"大众>
<span class=\"大众glyphicon glyphicon-search\公众 style=\"大众margin-top: 10px; float: left;\公众></span>
//关键字查询
<input type=\公众text\公众 class=\"大众form-control\"大众 name=\公众keyword\"大众 placeholder=\"大众关键字搜索\公众 style=\"大众max-width: 120px;float: left;\"大众>
<button type=\公众submit\公众 class=\公众btn btn-danger\公众style=\公众float: left; margin-left: 20px;\公众>搜索</button>
效果如图:
</div>
//利用表格在页面输出全部数据信息
<table class=\"大众table table-bordered\"大众>
<thead>
<tr>
<th>关键字</th>
<th>区域</th>
<th>屋子面积</th>
<th>租价</th>
<th>租房类型</th>
<th>户型</th>
</tr>
</thead>
<tbody>
<?php
$tj1 = \公众 1=1 \"大众; //分别对不同查询的条件做一个恒成立的条件
$tj2 = \"大众 1=1 \"大众;
$tj3 = \"大众 1=1 \"大众;
$tj4 = \"大众 1=1 \"大众;
if(!empty($_GET[\"大众qy\公众])){ //区域的条件判断
$qy = $_GET[\公众qy\"大众];
$str = implode(\"大众','\"大众, $qy);
$tj1 = \"大众area in ('{$str}')\"大众;
}
if(!empty($_GET[\公众zflx\公众])){ //租房类型的条件判断
$zflx = $_GET[\公众zflx\"大众];
$str = implode(\公众','\"大众, $zflx);
$tj2 = \公众renttype in ('{$str}')\公众;
}
if(!empty($_GET[\"大众hx\公众])){ //户型的条件判断
$hx = $_GET[\"大众hx\公众];
$str = implode(\公众','\公众, $hx);
$tj3 = \公众housetype in ('{$str}')\公众;
}
if(!empty($_GET[\"大众keyword\"大众])){ //关键字查询的条件判断
$keyword = $_GET[\"大众keyword\公众];
$tj4 = \公众keyword like '%{$keyword}%'\"大众;
}
$zts = \"大众select count() from housedb where {$tj1} and {$tj2} and {$tj3} and {$tj4}\"大众;
$ats = $db->query($zts,0);
$page = new page($ats[0][0],3); //分页查询取总数,设置每页显示的行数据
效果如图:
$sql = \"大众select from housedb where {$tj1} and {$tj2} and {$tj3} and {$tj4}\"大众.$page->limit; //利用拼接字符串办法将调取分页方法与条件进行拼接
$arr = $db->query($sql,0);
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>\"大众;
}
?>
</tbody>
</table>
效果如图:
<div>
<?php
echo $page->fpage();
?>
</div>
</div>
</form>
</body>
<script>
//利用JS实现全选功能
function qx(qx){
var ck1 = document.getElementsByClassName(\"大众ck1\"大众);
for(var i=0;i<ck1.length;i++){
ck1[i].checked=qx.checked;
}
}
function zflx(zflx){
var ck2 = document.getElementsByClassName(\"大众ck2\"大众);
for(var i=0;i<ck2.length;i++){
ck2[i].checked=zflx.checked;
}
}
function hx(hx){
var ck3 = document.getElementsByClassName(\公众ck3\"大众);
for(var i=0;i<ck3.length;i++){
ck3[i].checked=hx.checked;
}
}
</script>
</html>