<?php $db = new MySQLi("localhost","root","112834","hao"); $tj1 = "1=1"; $tj2 = "1=1"; $tj3 = "1=1"; $tj4 = "1=1"; if(!empty($_POST["qx"]) && count($_POST["qx"])>0) { $qx = $_POST["qx"]; $str = implode("‘,‘",$qx); $tj1 = " area in(‘{$str}‘) "; } if(!empty($_POST["zl"]) && count($_POST["zl"])>0) { $zl = $_POST["zl"]; $str = implode("‘,‘",$zl); $tj2 = " renttype in(‘{$str}‘) "; } if(!empty($_POST["fz"]) && count($_POST["fz"])>0) { $fw = $_POST["fz"]; $str = implode("‘,‘",$fz); $tj3 = " housetype in(‘{$str}‘) "; } if(!empty($_POST["key"])) { $key = $_POST["key"]; $tj4 = " keyword like ‘%{$key}%‘ "; } ?> <h1>租房子</h1> <form action="duoxuan.php" method="post" > <div>区域:<input type="checkbox" />全选</div> <div> <?php $sqlq = "select distinct area from fangzi"; $rq = $db->query($sqlq); $aq = $rq->fetch_all(); foreach($aq as $v) { echo"<input type=‘checkbox‘ name=‘qx[]‘ value=‘{$v[0]}‘ />{$v[0]}" ; } ?> </div> <div>租赁类型:<input type="checkbox" />全选</div> <div> <?php $sqlz = "select distinct renttype from fangzi"; $rz = $db->query($sqlz); $az = $rz->fetch_all(); foreach($az as $v) { echo"<input type=‘checkbox‘ name=‘zl[]‘ value=‘{$v[0]}‘ />{$v[0]}" ; } ?> </div> <div>房屋类型:<input type="checkbox" />全选</div> <div> <?php $sqlx = "select distinct hotsetype from fangzi"; $rx = $db->query($sqlx); $ax = $rx->fetch_all(); foreach($ax as $v) { echo"<input type=‘checkbox‘ name=‘fz[]‘ value=‘{$v[0]}‘ />{$v[0]}" ; } ?> </div> <div>关键字:<input type="text" name="key" /> <input type="submit" value="查询" /></div> </form> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>关键字</td> <td>区域</td> <td>面积</td> <td>租金</td> <td>租赁类型</td> <td>房屋类型</td> </tr> <?php $sqlall = "select * from fangzi"; $rall = $db->query($sqlall); $aall = $rall->fetch_all(); foreach($aall 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>
时间: 2024-11-05 21:40:53