租房子查询
1.發布房屋信息
發布頁面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> </head><body> <h1>發布新房</h1> <table> <form action="tianjiachuli.php" method="post"> <div>關鍵字: <input type="text" name="gjz" /></div> <div>區域: <input type="text" name="qy" /></div> <div>面積: <input type="text" name="mj" /></div> <div>租金: <input type="text" name="zj" /></div> <div>租賃類型:<input type="text" name="zllx" /></div> <div>房屋類型:<input type="text" name="fwlx" /></div> <input type="submit" value="插入" /> </form> <a href="chaxun.php"><input type="submit" value="取消" /></a></table></body> </html>發布房屋信息處理頁面代碼:
<?php $gjz = $_POST["gjz"]; $qy = $_POST["qy"]; $mj = $_POST["mj"]; $zj = $_POST["zj"]; $zllx = $_POST["zllx"]; $fwlx = $_POST["fwlx"];$db = new MySQLi("localhost","root","212333","HouseDB");$sql = "insert into house values('','{$gjz}','{$qy}','{$mj}','{$zj}','{$zllx}','{$fwlx}') ";$r = $db->query($sql);if($r) {header("location:chaxun.php"); } else {echo "失敗"; }?
2.查看房屋信息
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> </head><body> </a><a href="sousuo.php"><input type="submit" value="搜索" /></a> <form> <div></div> </form> <table width="100%" border="1" cellpadding="0" cellspacing="0"><tr><td></td><td></td><td>關鍵字</td><td>區域</td><td>使用面積</td><td>租金</td><td>租賃類型</td><td>房屋類型</td></tr><?php$db = new MySQLi("localhost","root","212333","HouseDB");$sql = "select * from house";$result = $db->query($sql);$attr = $result->fetch_all();foreach($attr as $j){echo "<tr><td><a href='bianji.php?upt=$j[0]'>編輯</a></td><td><a href='shanchuchuli1.php?ass=$j[0]' οnclick=\"return confirm('刪除確認')\">刪除</a></td><td>$j[1]</td><td>$j[2]</td><td>$j[3]</td><td>$j[4]</td><td>$j[5]</td><td>$j[6]</td></tr>"; }?> </table> <div><a href="tianjia1.php"><input type="submit" value="添加數據" /></div></body> </html>3.刪除和編輯處理頁面
編輯頁面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> </head><body><?php $upt = $_GET["upt"];$db = new MySQLi("localhost","root","212333","HouseDB");$sql = "select * from house where id='{$upt}'";$rrr = $db->query($sql);$attr = $rrr->fetch_all();foreach($attr as $v) ?><h1>編輯</h1> <table> <form action="bianjichuli.php" method="post"> <input type="hidden" name="id" value="<?php echo $v[0] ?>" /> <div>關鍵字:<input type="text" name="gjz" value="<?php echo $v[1] ?>" /></div> <div>區域:<input type="text" name="qy" value="<?php echo $v[2] ?>" /></div> <div>面積:<input type="text" name="mj" value="<?php echo $v[3] ?>" /></div> <div>租金:<input type="text" name="zj" value="<?php echo $v[4] ?>" /></div> <div>租賃類型:<input type="text" name="zllx" value="<?php echo $v[5] ?>" /></div> <div>房屋類型:<input type="text" name="fwlx" value="<?php echo $v[6] ?>" /></div> <input type="submit" value="更新" /> </form> <a href="chaxun.php"><input type="submit" value="取消" /></a></table></body> </html>?
編輯處理頁面代碼:
<?php $id = $_POST["id"]; $gjz = $_POST["gjz"]; $qy = $_POST["qy"]; $mj = $_POST["mj"]; $zj = $_POST["zj"]; $zllx = $_POST["zllx"]; $fwlx = $_POST["fwlx"];$db = new MySQLi("localhost","root","212333","HouseDB");$sql = "update house set KeyWord='{$gjz}',Area='{$qy}',SquareMeter='{$mj}',Rent='{$zj}',RentType='{$zllx}',HouseType ='{$fwlx}' where id='{$id}'";$r = $db->query($sql); echo $sql; if($r) {header("location:chaxun.php"); } else {echo "失敗"; }(2)刪除處理頁面代碼
<?php$aa = $_GET["ass"];$db = new MySQLi("localhost","root","212333","HouseDB");$sql = "delete from house where id='{$aa}' ";$r = $db->query($sql);if($r) {header("location:chaxun.php"); } else {echo "失敗"; }4.條件查詢頁面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>無標題文檔</title> </head><body> <form action="sousuo.php" method="post"> <div>區 域:<input type="checkbox" οnclick="checkall(this)" />全選</div> <div><input type="checkbox" name="a[]" value="坂井" class="qx1" />坂井<input type="checkbox" name="a[]" value="三義廟" class="qx1"/>三義廟<input type="checkbox" name="a[]" value="上上城" class="qx1" />上上城<input type="checkbox" name="a[]" value="天安門東" class="qx1" />天安門東<input type="checkbox" name="a[]" value="中關村" class="qx1" />中關村 </div> <br /><div>租賃類型:<input type="checkbox" οnclick="checkall2(this)" />全選</div> <div><input type="checkbox" name="b[]" class="qx2"/>床位<input type="checkbox" name="b[]" class="qx2"/>合租<input type="checkbox" name="b[]" class="qx2"/>整租 </div> <br /><div>房屋類型:<input type="checkbox" name="qx" οnclick="checkall3(this)" />全選</div> <div><input type="checkbox" name="c[]" class="qx3" />1室1廳<input type="checkbox" name="c[]" class="qx3" />2室1廳<input type="checkbox" name="c[]" class="qx3" />3室2廳<input type="checkbox" name="c[]" class="qx3" />4室2廳<input type="checkbox" name="c[]" class="qx3" />平房<input type="checkbox" name="c[]" class="qx3" />筒子樓 </div> <br /> <div>關鍵字:<input type="text" name="gjz" /> </div> <br /> <div><input type="submit" value="搜索" /></div> </form> <br /><br /> <br /><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["a"]) && count($_POST["a"])>0) {$a = $_POST["a"];$b = implode("','",$a);$tj1 = " area in('{$b}') "; }if(!empty($_POST["b"]) && count($_POST["b"])>0) {$b = $_POST["b"];$c = implode("','",$b);$tj2 = " area in('{$c}') "; }if(!empty($_POST["c"]) && count($_POST["c"])>0) {$c = $_POST["c"];$d = implode("','",$c);$tj3 = " area in('{$d}') "; }if(!empty($_POST["gjz"])) {$gjz = $_POST["gjz"];$tj4 = " keyword like '%{$gjz}%' "; }$db = new MySQLi("localhost","root","212333","HouseDB");$sqls = "select * from house where {$tj1} and {$tj2} and {$tj3} and {$tj4}";$results = $db->query($sqls);$attr = $results->fetch_all();foreach($attr as $j){echo "<tr><td>$j[1]</td><td>$j[2]</td><td>$j[3]</td><td>$j[4]</td><td>$j[5]</td><td>$j[6]</td></tr>"; }?></table></body><script type="text/javascript">function checkall(a) {var ck = document.getElementsByClassName("qx1");if(a.checked){for(var i=0;i<ck.length;i++){ck[i].setAttribute("checked","checked");}}else{for(var i=0;i<ck.length;i++){ck[i].removeAttribute("checked");}} }function checkall2(a) {var ck = document.getElementsByClassName("qx2");if(a.checked){for(var i=0;i<ck.length;i++){ck[i].setAttribute("checked","checked");}}else{for(var i=0;i<ck.length;i++){ck[i].removeAttribute("checked");}} } function checkall3(a) {var ck = document.getElementsByClassName("qx3");if(a.checked){for(var i=0;i<ck.length;i++){ck[i].setAttribute("checked","checked");}}else{for(var i=0;i<ck.length;i++){ck[i].removeAttribute("checked");}} }</script> </html>?
轉載于:https://www.cnblogs.com/chaochao00o/p/6227319.html
總結
- 上一篇: MFC CTreeCtrl运用
- 下一篇: vue.js几行实现的简单的todo l