zoukankan      html  css  js  c++  java
  • 搜 房 网 站 设 计 练 习

     

    搜房网主页面

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     5 <title>搜房网主页面</title>
     6 </head>
     7 
     8 <body>
     9 <table width="100%" border="1" cellpadding="0" cellspacing="0">
    10     <tr>
    11     
    12      <td style=" font-size:18px; font-weight:bold">唯一标识</td>
    13     <td style=" font-size:18px; font-weight:bold">关键字</td>
    14     <td style=" font-size:18px; font-weight:bold">所属区域</td>
    15     <td style=" font-size:18px; font-weight:bold">使用面积(平米)</td>
    16     <td style=" font-size:18px; font-weight:bold">租金(每月)</td>
    17     <td style=" font-size:18px; font-weight:bold">租赁类型</td>
    18     <td style=" font-size:18px; font-weight:bold">房屋类型</td>
    19     <td style=" font-size:18px; font-weight:bold">操作</td>
    20     
    21     </tr>
    22 
    23 <?php
    24 
    25 include("soufang_chuli.php");
    26 $db = new DBDA();
    27 
    28 $sql = "select * from house";
    29 $attr = $db->Query($sql);
    30 
    31 foreach($attr as $v)
    32 {
    33     echo "<tr>";
    34     
    35     echo "<td>{$v[0]}</td><td>{$v[1]}</td><td>{$v[2]}</td><td>{$v[3]}</td><td>{$v[4]}</td><td>{$v[5]}</td><td>{$v[6]}</td><td><a href='SFshanchu_chuli.php?c={$v[0]}' onclick="return confirm('确定删除吗???')">删除</a>&nbsp;|&nbsp;<a href='SFxiugaiNR.php?c={$v[0]}'>修改</a></td>";
    36     
    37     echo "</th>";
    38     
    39 }
    40 
    41 
    42 
    43 ?>
    44 
    45 
    46 
    47 
    48 
    49 </table>
    50 
    51 <br />
    52 <br />
    53 <a href="SFtianjiashuju.php"><input type="button" value="添加数据" /></a>
    54 <a href="SFduotiaojianCX.php"><input type="button" value="高级查询" /></a>
    55 
    56 
    57 </body>
    58 </html>

    搜房网效果显示

     

     

    搜房处理界面   链接数据库公用的,只要连接数据库都会调用这个处理界面

     1 <!--搜房网处理页面-->
     2 
     3 
     4 <?php
     5 
     6 class DBDA   //PHP链接MySQL先定义一个类
     7 {
     8     //分装下面这四个类名字可以随便取
     9     public $host="localhost";   //pudlic  公众的,给ip地址一个接受的名$host
    10     
    11     public $uid ="root";  //MySQL软件名,给软件名一个接受的名  $uid
    12     
    13     public $pwd ="123456";   //MySQL软件密码,给密码一个接受的名  $pwd
    14     
    15     public $dbname="housedb";  //要连接的数据库名
    16         
    17     
    18     function Query($sql,$type=1)
    19     {
    20         //造连接对象
    21         $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
    22         
    23         //执行sql语句
    24         $reslut = $db->query($sql);
    25         
    26         //从结果集对象里面取数据
    27         if($type==1)
    28         {
    29             return $reslut->fetch_all();
    30             
    31         }
    32         else
    33         {
    34             return $reslut;
    35         }
    36         
    37         
    38     }
    39     
    40     
    41     
    42     
    43 }
    44 
    45 
    46 
    47 
    48 ?>

     

     删除处理界面

     1 <!--删除处理-->
     2 
     3 
     4 <?php
     5 include("soufang_chuli.php");
     6 $db = new DBDA();
     7 
     8 $ID = $_GET["c"];
     9 
    10 //写sql语句
    11 $sql = "delete from house where ID='{$ID}'";
    12 
    13 
    14 //执行sql语句
    15 $attr = $db->Query($sql,0);
    16 
    17 var_dump($attr);
    18 
    19 if($attr)
    20 {
    21     header("location:soufang.php");
    22 }
    23 else   //判断删除失败,正常删除是不会出现这个情况的。
    24 {
    25     echo "删除失败";
    26 }

     

    修改显示界面

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     5 <title></title>
     6 </head>
     7 
     8 <body>
     9 <!--搜房修改修改显示页面-->
    10 <?php
    11 
    12 
    13 //接受一下客户要改的那个房源
    14 $ID = $_GET["c"];
    15 
    16 
    17 
    18 
    19 //连接对象
    20 
    21 include("soufang_chuli.php");
    22 $db = new DBDA();
    23 
    24 //写SQL语句
    25 $sql = "select * from house where ID='{$ID}'";
    26 
    27 
    28 //执行SQL语句
    29 
    30 $attr = $db->Query($sql,1);
    31 
    32 foreach($attr as $v){
    33         $v;
    34     }
    35     
    36 ?>
    37 
    38 
    39 <div><h1>修改房源</h1></div>
    40 
    41 <form action="SFxiugai_chuli.php" method="post">
    42 
    43 <div style="300px; height:300px;">
    44 
    45 <div style="100px; height:300px; background-color:#900; float:left">
    46 
    47     <div>关键字:</div>
    48     <div>区域:</div>
    49     <div>使用面积:</div>
    50     <div>租金:</div>
    51     <div>租赁类型:</div>
    52     <div>房屋类型:</div>
    53 
    54 
    55 </div>
    56 
    57 <div style="180px; height:300px; background-color:#0C3; float:left">
    58     <div><input type="hidden" name="ID" value="<?php echo $v[0]; ?>"  /></div>
    59     <div><input type="text" name="keyword" value="<?php echo $v[1]; ?>" /></div>
    60     <div><input type="text" name="Area"  value="<?php echo $v[2]; ?>"/></div>
    61     <div><input type="text" name="squaremeter" value="<?php echo $v[3]; ?>" /></div>
    62     <div><input type="text" name="Rent" value="<?php echo $v[4]; ?>" /></div>
    63     <div><input type="text" name="RentType" value="<?php echo $v[5]; ?>" /></div>
    64     <div><input type="text" name="HouseType" value="<?php echo $v[6]; ?>" /></div>
    65 
    66 </div>
    67 
    68 
    69 
    70 
    71 
    72 
    73 </div>
    74 
    75 
    76 <div><input type="submit" value="更新" /></div>&nbsp;&nbsp;&nbsp;
    77 <div><input type="submit" value="取消" /></div>
    78 
    79 
    80 
    81 
    82 </form>
    83 
    84 
    85 
    86 
    87 
    88 
    89 
    90 
    91 
    92 
    93 </body>
    94 </html>

     

    显示界面效果图

     

     

     

    修改处理界面

     

     1 <!--搜房信息修改处理-->
     2 
     3 <?php
     4 
     5     //链接对象
     6     include("soufang_chuli.php");
     7     $db = new DBDA();
     8     
     9     
    10     $ID = $_POST["ID"];
    11     $a = $_POST["keyword"];
    12     $b = $_POST["Area"];
    13     $c = $_POST["squaremeter"];
    14     $d = $_POST["Rent"];
    15     $e = $_POST["RentType"];
    16     $f = $_POST["HouseType"];
    17     
    18 
    19 
    20     //写sql语句
    21     $sql = "update house set keyword='{$a}',Area='{$b}',squaremeter='{$c}',Rent='{$d}',RentType='{$e}',HouseType='{$f}' where ID='{$ID}'";
    22 
    23         
    24     //执行sql语句
    25     $a = $db->Query($sql,0);
    26     
    27     if($a){
    28         echo "修改成功";
    29         }
    30         else
    31         {
    32             echo "修改失败失败";
    33         }
    34     
    35 
    36 ?>
    37 
    38 <a href="soufang.php" >查看内容</a>

     

     

    添加显示界面

     

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     5 <title>添加数据</title>
     6 </head>
     7 
     8 <body>
     9 
    10 <form action="SFtianjia_chuli.php" method="post">
    11 
    12 <div style="300px; height:300px;">
    13 
    14 <div style="100px; height:300px; background-color:#900; float:left">
    15 
    16     <div>关键字:</div>
    17     <div>区域:</div>
    18     <div>使用面积:</div>
    19     <div>租金:</div>
    20     <div>租赁类型:</div>
    21     <div>房屋类型:</div>
    22 
    23 
    24 </div>
    25 
    26 <div style="180px; height:300px; background-color:#0C3; float:left">
    27     <div><input type="hidden" name="ID"  /></div>
    28     <div><input type="text" name="keyword" /></div>
    29     <div><input type="text" name="Area" /></div>
    30     <div><input type="text" name="squaremetr" /></div>
    31     <div><input type="text" name="Rent" /></div>
    32     <div><input type="text" name="HouseType" /></div>
    33     <div><input type="text" name="RentType" /></div>
    34 
    35 </div>
    36 
    37 
    38 
    39 
    40 
    41 </div>
    42 
    43 
    44 <div><input type="submit" value="添加" /></div>
    45 
    46 
    47 
    48 
    49 
    50 </form>
    51 
    52 
    53 </body>
    54 </html>

     

     

    添加界面效果图

     

     

     

    添加处理界面

     

     1 <!--添加处理-->
     2 
     3 <?php
     4 
     5 
     6     include("soufang_chuli.php");
     7     $db = new DBDA();
     8 
     9 
    10 
    11     $ID = $_POST["ID"];
    12     $keyword = $_POST["keyword"];
    13     $Area = $_POST["Area"];
    14     $squaremetr = $_POST["squaremetr"];
    15     $Rent = $_POST["Rent"];
    16     $HouseType = $_POST["HouseType"];
    17     $RentType = $_POST["RentType"];
    18 if(!empty($keyword) && !empty($Area) && !empty($squaremetr) && !empty($Rent) && !empty($HouseType) && !empty($RentType))
    19 {
    20 
    21     //写sql语句
    22     $sql = "insert into house values('{$ID}','{$keyword}','{$Area}','{$squaremetr}','{$Rent}','{HouseType}','{$RentType}')";
    23         
    24     //执行sql语句
    25     $a=$db->Query($sql,0);
    26     if($a){
    27         echo "添加成功";
    28         }
    29         else
    30         {
    31             echo "添加失败";
    32         }
    33     
    34     
    35     //输出跳转到添加成功页面
    36     //header("location:tianjiaSJ_chuli.php");
    37 }
    38 else
    39 {
    40     echo "<h1>请完善房源!!!</h1>
    41     <br>
    42     <br>
    43     <a href='SFtianjiashuju.php'>返回重写填写</a>
    44     
    45     <br>
    46     <br>
    47     
    48     <a href='soufang.php'>查看已有房源</a>";
    49 }
    50 
    51 ?>
    52 &nbsp;&nbsp;
    53 <a href="soufang.php">查看</a>
    54 &nbsp;&nbsp;
    55 <a href="SFtianjiashuju.php">继续添加</a>

     

     

     

    多条件查询显示界面

     

      1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <head>
      4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      5 <title>多条件查询</title>
      6 </head>
      7 
      8 <!--
      9 distinctq 去重
     10 
     11 
     12 -->
     13 
     14 
     15 
     16 <body>
     17 
     18 <?php
     19 include("soufang_chuli.php");
     20 $db = new DBDA();
     21 
     22 ?>
     23 
     24 <form action="SFduotiaojianCX.php" method="post">
     25 
     26 <div>区域:<input type="checkbox" onclick="checkall(this,'qx')" />全选</div>
     27 <div>
     28         <?php
     29                 $sarea = "select distinct area from house";
     30                 $aarea = $db->Query($sarea);
     31                 
     32                 foreach($aarea as $v)
     33                 {
     34                     echo "<input type='checkbox' value='{$v[0]}' name='qx[]'class='qx' />{$v[0]}";
     35                     
     36                 }
     37         
     38         
     39         ?>
     40 
     41 </div>
     42 
     43 <br />
     44 <div>租赁类型: <input type="checkbox" onclick="checkall(this,'zllx')" />全选</div>
     45 
     46 <div>
     47         <?php
     48             $szllx = "select distinct renttype from house";
     49             $azllx = $db->Query($szllx);
     50             
     51             foreach($azllx as $v)
     52             {
     53                 echo "<input type='checkbox' value='{$v[0]} ' name='zllx[]' class='zllx' />{$v[0]}";
     54                 
     55             }        
     56         
     57         
     58         ?>
     59 
     60 </div>
     61 
     62 <br />
     63 
     64 <div>房屋类型: <input type="checkbox" onclick="checkall(this,'fwlx')" /></div>
     65 
     66 <div>
     67             <?php
     68             
     69                     $sfwlx = "select distinct housetype from house";
     70                     $afwlx = $db->Query($sfwlx);
     71                     
     72                     foreach($afwlx as $v)
     73                     {
     74                         echo "<input type='checkbox' value='{$v[0]}' name='fwlx[]' class='fwlx' />{$v[0]}";
     75                     }
     76             
     77             ?>
     78 
     79 </div>
     80 <br />
     81 
     82 <div>关键字:<input type="text"  name="keyword"/></div>
     83 
     84 <div><input type="submit" value="查询" /></div>
     85 
     86 </form>
     87 
     88 <br />
     89 
     90 <table width="100%" border="1" cellpadding="0" cellspacing="0">
     91 
     92         <tr>
     93             <td>关键字</td>
     94             <td>区域</td>
     95             <td>建筑面积</td>
     96             <td>租金</td>
     97             <td>租赁类型</td>
     98             <td>房屋类型</td>
     99         
    100         </tr>
    101 
    102 <?php
    103         
    104         //多条件查询
    105         $tj1 = " 1=1 ";
    106         $tj2 = " 1=1 ";
    107         $tj3 = " 1=1 ";
    108         $tj4 = " 1=1 ";
    109         
    110         //判断区域
    111         if(!empty($_POST["qx"])&& count($_POST["qx"])>0)
    112         
    113         {
    114             $str = implode("','",$_POST["qx"]);
    115             $tj1 = " area in ('{$str}') ";
    116         }
    117         
    118         //判断租赁类型
    119         if(!empty($_POST["zllx"])&& count($_POST["zllx"])>0)
    120         {
    121             $str = implode("','",$_POST["zllx"]);
    122             $tj2 = " renttype in ('{$str}') ";
    123         }
    124         //判断房屋类型
    125         if(!empty($_POST["fwlx"])&& count($_POST["fwlx"])>0)
    126         {
    127             $str = implode("','",$_POST["fwlx"]);
    128             $tj3 = " housetype in ('{$str}') ";
    129         }
    130         //判断关键字
    131         if(!empty($_POST["keyword"]))
    132         {
    133             $tj4 = " keyword like '%{$_POST['keyword']}%' ";
    134         }
    135         
    136         
    137         
    138         $sall = "select * from house where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
    139         
    140         $aall = $db->Query($sall);
    141         
    142         
    143         foreach($aall as $v)
    144         {
    145             
    146             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>";
    147         }
    148         
    149 
    150 ?>
    151 
    152 
    153 
    154 </table>
    155 
    156 
    157 
    158 <script type="text/javascript">
    159 
    160 function checkall(d,a)
    161 {
    162     var ck = document.getElementsByClassName(a);
    163     
    164     
    165     for(var i=0;i<ck.length;i++)
    166     {
    167         if(d.checked)
    168         {
    169                 ck[i].setAttribute("checked","checked");
    170         }
    171         else
    172         {
    173                 ck[i].removeAttribute("checked");
    174         }
    175     }
    176 }
    177 
    178 
    179 
    180 </script>

     

     

     

     多条件查询效果图

     

     

     

     

     

  • 相关阅读:
    [工作札记]01: CS系统中分页控件的制作
    【非技术】试占新型肺炎的情况与发展趋势
    给培训学校讲解ORM框架的课件
    SAAS云平台搭建札记: (二) Linux Ubutu下.Net Core整套运行环境的搭建
    SAAS云平台搭建札记: (一) 浅论SAAS多租户自助云服务平台的产品、服务和订单
    开源三维地球GIS引擎Cesium常用功能的开发
    Asp.net管理信息系统中数据统计功能的实现
    [Thrift]学习使用Thrift
    使用Netty实现一下简单RPC
    [Redis]Redis做简单的分布式限流
  • 原文地址:https://www.cnblogs.com/zc290987034/p/6036552.html
Copyright © 2011-2022 走看看