查询文件(search.php)
一、生成查询语句:
复制代码 代码如下:
<?
$conn=mysql_connect("localhost","root","");
$db=mysql_select_db("lingyun");
$query="select * from message where tradetype='".$tradetype."'"; //交易类型,如出租,出售
$SQL=$SQL . "wuye='" . $wuye . "'";
if($housetype!="不限"){
$query.=" && housetype='".$housetype."'"; //房屋类型,如二室一厅,三室二厅
}
if($degree!="不限"){
$query.=" && degree='".$degree."'"; //新旧程度
}
if($wuye!="不限"){
$query.=" && wuye='".$wuye."'"; //物业类型 如住房,商铺
}
if($price2!=""){
switch($price1){
case "大于":
$query.=" && price>'".$price2."'"; //价格
break;
case "等于":
$query.=" && price='".$price2."'";
break;
case "小于":
$query.=" && price<'".$price2."'";
break;
}
}
if($area2!=""){
switch($area1){
case "大于":
$query.=" && area>'".$area2."'"; //面积
break;
case "等于":
$query.=" && area='".$area2."'";
break;
case "小于":
$query.=" && area<'".$area2."'";
break;
}
}
switch($pubdate){ //发布日期
case "本星期内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=7";
break;
case "一个月内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=30";
break;
case "三个月内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=91";
break;
case "六个月内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=183";
break;
}
if($address!=""){
$query.=" && address like '%$address%'"; //地址
}
if(!$page){
$page=1;
}
?>
二、输出查询结果:
复制代码 代码如下:
<?php
if ($page){
$page_size=20;
$result=mysql_query($query);
#$message_count=mysql_result($result,0,"total");
$message_count=10;
$page_count=ceil($message_count/$page_size);
$offset=($page-1)*$page_size;
$query=$query." order by date desc limit $offset, $page_size";
$result=mysql_query($query);
if($result){
$rows=mysql_num_rows($result);
if($rows!=0){
while($myrow=mysql_fetch_array($result)){
echo "<tr>";
echo "<td width='15' height='12'><img src='image/home2.gif' width='14' height='14'></td>";
echo "<td width='540' height='12'>$myrow[id] $myrow[tradetype] $myrow[address] $myrow[wuye]($myrow[housetype])<font style='font-size:9pt'>[$myrow[date]]</font>";
echo "</td>";
echo "<td width='75' height='12'><a href='view_d.php?code=$myrow[code]' target='_blank'>详细内容</a></td>";
echo "</tr>";
}
}
else echo "<tr><td><div align='center'><img src='image/sorry.gif'><br><br>没有找到满足你条件的记录</div>& lt;/td></tr>";
}
$prev_page=$page-1;
$next_page=$page 1;
echo "<div align='center'>";
echo " 第".$page."/".$page_count."页 ";
if ($page<=1){
echo "|第一页|";
}
else{
echo "<a href='$PATH_INFO?page=1'>|第一页|</a>";
}
echo " ";
if ($prev_page<1){
echo "|上一页|";
}
else{
echo "<a href='$PATH_INFO?page=$prev_page'>|上一页|</a>";
}
echo " ";
if ($next_page>$page_count){
echo "|下一页|";
}
else{
echo "<a href='$PATH_INFO?page=$next_page'>|下一页|</a>";
}
echo " ";
if ($page>=$page_count){
echo "|最后一页|";
}
else{
echo "<a href='$PATH_INFO?page=$page_count'>|最后一页|</a>";
}
echo "</div>";
}
else{
echo "<p align='center'>现在还没有房屋租赁信息!</p>";
}
echo "<hr width="100%" size="1">";
?>
</table>
一、生成查询语句:
复制代码 代码如下:
<?
$conn=mysql_connect("localhost","root","");
$db=mysql_select_db("lingyun");
$query="select * from message where tradetype='".$tradetype."'"; //交易类型,如出租,出售
$SQL=$SQL . "wuye='" . $wuye . "'";
if($housetype!="不限"){
$query.=" && housetype='".$housetype."'"; //房屋类型,如二室一厅,三室二厅
}
if($degree!="不限"){
$query.=" && degree='".$degree."'"; //新旧程度
}
if($wuye!="不限"){
$query.=" && wuye='".$wuye."'"; //物业类型 如住房,商铺
}
if($price2!=""){
switch($price1){
case "大于":
$query.=" && price>'".$price2."'"; //价格
break;
case "等于":
$query.=" && price='".$price2."'";
break;
case "小于":
$query.=" && price<'".$price2."'";
break;
}
}
if($area2!=""){
switch($area1){
case "大于":
$query.=" && area>'".$area2."'"; //面积
break;
case "等于":
$query.=" && area='".$area2."'";
break;
case "小于":
$query.=" && area<'".$area2."'";
break;
}
}
switch($pubdate){ //发布日期
case "本星期内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=7";
break;
case "一个月内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=30";
break;
case "三个月内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=91";
break;
case "六个月内":
$query.=" && TO_DAYS(NOW()) - TO_DAYS(date)<=183";
break;
}
if($address!=""){
$query.=" && address like '%$address%'"; //地址
}
if(!$page){
$page=1;
}
?>
二、输出查询结果:
复制代码 代码如下:
<?php
if ($page){
$page_size=20;
$result=mysql_query($query);
#$message_count=mysql_result($result,0,"total");
$message_count=10;
$page_count=ceil($message_count/$page_size);
$offset=($page-1)*$page_size;
$query=$query." order by date desc limit $offset, $page_size";
$result=mysql_query($query);
if($result){
$rows=mysql_num_rows($result);
if($rows!=0){
while($myrow=mysql_fetch_array($result)){
echo "<tr>";
echo "<td width='15' height='12'><img src='image/home2.gif' width='14' height='14'></td>";
echo "<td width='540' height='12'>$myrow[id] $myrow[tradetype] $myrow[address] $myrow[wuye]($myrow[housetype])<font style='font-size:9pt'>[$myrow[date]]</font>";
echo "</td>";
echo "<td width='75' height='12'><a href='view_d.php?code=$myrow[code]' target='_blank'>详细内容</a></td>";
echo "</tr>";
}
}
else echo "<tr><td><div align='center'><img src='image/sorry.gif'><br><br>没有找到满足你条件的记录</div>& lt;/td></tr>";
}
$prev_page=$page-1;
$next_page=$page 1;
echo "<div align='center'>";
echo " 第".$page."/".$page_count."页 ";
if ($page<=1){
echo "|第一页|";
}
else{
echo "<a href='$PATH_INFO?page=1'>|第一页|</a>";
}
echo " ";
if ($prev_page<1){
echo "|上一页|";
}
else{
echo "<a href='$PATH_INFO?page=$prev_page'>|上一页|</a>";
}
echo " ";
if ($next_page>$page_count){
echo "|下一页|";
}
else{
echo "<a href='$PATH_INFO?page=$next_page'>|下一页|</a>";
}
echo " ";
if ($page>=$page_count){
echo "|最后一页|";
}
else{
echo "<a href='$PATH_INFO?page=$page_count'>|最后一页|</a>";
}
echo "</div>";
}
else{
echo "<p align='center'>现在还没有房屋租赁信息!</p>";
}
echo "<hr width="100%" size="1">";
?>
</table>
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年11月18日
2024年11月18日
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】