練習 租房子

2022-07-29 02:45:09 字數 3778 閱讀 6238

示例圖:

圖1

圖2                                            圖3

圖4題目做法:

建立資料庫

封裝類檔案:

class

fengzhuang

else

}//返回關聯陣列

function glquery($sql,$type=1)

return

$attr

;

}else

}//返回接字串

function

zfcquery()

return

substr($str,0,strlen($str)-1);

}else}}

首頁:

操作

代號關鍵字

所屬區域

使用面積(平公尺)

租金(每月)

租賃型別

房屋型別

<?php

include("fengzhuang.class.php");

$db = new

fengzhuang();

$sql = "select * from house";

$attr = $db->query($sql

);foreach($attr

as$v

)' onclick=\"return confirm('主人真的不要我了嗎?')\">刪除

$v[0]}'>修改

";

echo "";

}?>

新增頁面:

新增處理:

<?php 

$id = $_post["id"];

$keyword = $_post["keyword"];

$area = $_post["area"];

$squaremeter = $_post["squaremeter"];

$rent = $_post["rent"];

$renttype = $_post["renttype"];

$housetype = $_post["housetype"];

include("fengzhuang.class.php");

$db = new

fengzhuang();

$sql = "insert into house value('','','','','','','')";

$db->query($sql,0);

header("location:tianjia.php");

刪除處理:

<?php 

$id = $_get["c"];

include("fengzhuang.class.php");

$db = new

fengzhuang();

$sql = "delete from house where id=''";

$db->query($sql,0);

header("location:zhuye.php");

修改頁面:

<?php 

$id = $_get["c"];

include("fengzhuang.class.php");

$db = new

fengzhuang();

$sql = "select * from house where id=''";

$ahouse = $db->query($sql

);$a = $ahouse[0];

?>

修改處理:

<?php 

$id = $_post["id"];

$keyword = $_post["keyword"];

$area = $_post["area"];

$squaremeter = $_post["squaremeter"];

$rent = $_post["rent"];

$renttype = $_post["renttype"];

$housetype = $_post["housetype"];

include("fengzhuang.class.php");

$db = new

fengzhuang();

$sql = "update house set keyword='',area='',squaremeter='',rent='',

renttype='',housetype='' where id=''";

$db->query($sql,0);

header("location:zhuye.php");

條件搜尋頁面(全選):

<?php 

include("fengzhuang.class.php");

$db = new

fengzhuang();

?>

關鍵字區域

建築面積

租金租賃型別

房屋型別

<?php

//多條件查詢

$tj1 = " 1=1 ";

$tj2 = " 1=1 ";

$tj3 = " 1=1 ";

$tj4 = " 1=1 ";

//判斷區域

if(!empty($_post["qx"])&& count($_post["qx"])>0)

') ";

}//判斷租賃型別

if(!empty($_post["zllx"])&&count($_post["zllx"])>0)

') ";

}//判斷房屋型別

if(!empty($_post["fwlx"])&&count($_post["fwlx"])>0)

') ";

}//判斷關鍵字

if(!empty($_post["keyword"]))

%' ";

}$sall = "select * from housedb where and and and ";

$aall = $db->query($sall

);

echo

$sall

;

foreach($aall

as$v

)

"; }

?>

練習 租房子

原資料 根據 1,做篩選條件 2,查詢 租房 如下 attr post qy attr2 post qyy attr3 post qyyy attr4 post gj str implode attr str2 implode attr2 str3 implode attr3 因為接收資料是陣列,所...

租房子練習

create table zufang id int auto increment primary key,keyword intcomment 關鍵字 area varchar 50 comment 所屬區域 squaremeter intcomment 使用面積 平方公尺 rent float ...

租房子隨想

之前 看到街頭到處都有很多房產中介,我很莫名,難道中介的蛋糕真的有這麼大麼?知道這幾天租房子才發現,的確大,很大。最近因為公司搬家,搞得自己也必須搬家,所以就忙著搬家,結果找了好久都沒有發現好的房子,最後只好找中介,中介一看到我真是和看到上帝一樣的興奮 難道我長得就象凱子?然後聽我的要求說 我帶你去...