相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
- PHP中opcode緩存簡(jiǎn)單用法分析
- thinkPHP控制器變量在模板中的顯示方法示例
- PHP move_uploaded_file() 函數(shù)(將上傳的文件移動(dòng)到新位置)
- dirname(__FILE__)的含義和應(yīng)用說明
- thinkPHP5框架實(shí)現(xiàn)分頁(yè)查詢功能的方法示例
- PHP中單雙號(hào)與變量
- PHP獲得當(dāng)日零點(diǎn)時(shí)間戳的方法分析
- Laravel ORM對(duì)Model::find方法進(jìn)行緩存示例詳解
- PHP讀寫文件高并發(fā)處理操作實(shí)例詳解
- 【CLI】利用Curl下載文件實(shí)時(shí)進(jìn)度條顯示的實(shí)現(xiàn)
php出租房數(shù)據(jù)管理及搜索頁(yè)面

php數(shù)據(jù)訪問例子:租房信息管理,具體內(nèi)容如下
1.數(shù)據(jù)庫(kù)建表
2. zufangzi.php
<body> <h1>租房子</h1> <form action="zufangzi.php" method="post"> <div>區(qū)域:<input type="checkbox" name="qx" onclick="quanxuan(this,'qy')" />全選</div> <div> <?php require "DBDA.class1.php"; $db = new DBDA(); $sqy = "select distinct area from house";//寫SQL語(yǔ)句,并去重 $aqy = $db->query($sqy); foreach($aqy as $v) { echo "<input type='checkbox' name='qy[]' value='{$v[0]}' class='qy' />{$v[0]}"; } ?> </div> <br /> <div>租賃類型:<input type="checkbox" name="zlqx" onclick="quanxuan(this,'zl')" />全選</div> <div> <?php $szl = "select distinct renttype from house"; $azl = $db->query($szl); foreach($azl as $v) { echo "<input type='checkbox' name='zl[]' value='{$v[0]}' class='zl' />{$v[0]}"; } ?> </div> <br /> <div>房屋類型:<input type="checkbox" name="fwqx" onclick="quanxuan(this,'fw')" />全選</div> <div> <?php $sfw = "select distinct housetype from house"; $afw = $db->query($sfw); foreach($afw as $v) { echo "<input type='checkbox' name='fw[]' value='{$v[0]}' class='fw' />{$v[0]}"; } ?> </div> <br /> <div>關(guān)鍵字:<input type="text" name="key" /> <input type="submit" value="查詢" /></div> </form> <br /> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>關(guān)鍵字</td> <td>區(qū)域</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["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 "<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>"; } ?> </table> </body> <script type="text/javascript"> function quanxuan(qx,a) { //找到該全選按鈕對(duì)應(yīng)的checkbox列表 var ck = document.getElementsByClassName(a); //找全選按鈕選中狀態(tài) if(qx.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>