租房子查询

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>关键字:&nbsp;<input type="text" name="gjz" /></div>
<div>区域:&nbsp;&nbsp;<input type="text" name="qy" /></div>
<div>面积:&nbsp;&nbsp;<input type="text" name="mj" /></div>
<div>租金:&nbsp;&nbsp;<input type="text" name="zj" /></div>
<div>租赁类型:<input type="text" name="zllx" /></div>
<div>房屋类型:<input type="text" name="fwlx" /></div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="插入" />
</form>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="更新" />
</form>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>区&nbsp;&nbsp;域:<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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值