zoukankan      html  css  js  c++  java
  • 实例五租房子

    前台

    <!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 method="post" action="qiantai.php">
    <?php
    $db=new mysqli("localhost","root","","1");
    !mysqli_connect_error() or die("连接错误");
    $sql="select  * from house";
    $result=$db->query($sql);
    $attr=$result->fetch_all();
    
    ?>
    <div>区域</div><div><input type="checkbox"  class="aa" onclick="CheckAll(this,'aa')" />全选</div>
    
    <?php
    foreach ($attr as $v)//多维数组化一位数组
    {    
       $a1[]=$v[2];  //数组赋值
    }
    $b1=array_unique($a1);//去重
    foreach ($b1 as $c1)
    {
    	   echo "<div><input type='checkbox' class='aa' name='kz1[]' value='{$c1}' />{$c1}</div>";
    }
    ?>
    <div>租赁类型</div><div><input type="checkbox"  class="bb" onclick="CheckAll(this,'bb')"  />全选</div>
    <?php
    foreach ($attr as $v)//多维数组化一位数组
    {    
       $a2[]=$v[5];  //数组赋值
    }
    $b2=array_unique($a2);//去重
    foreach ($b2 as $c2)
    {
    	   echo "<div><input type='checkbox' class='bb' name='kz2[]' value='{$c2}' />{$c2}</div>";
    }
    
    ?>
    <div>房屋类型</div><div><input type="checkbox" class="cc"  onclick="CheckAll(this,'cc')" />全选</div>
    <?php
    foreach ($attr as $v)//多维数组化一位数组
    {    
       $a3[]=$v[6];  //数组赋值
    }
    $b3=array_unique($a3);//去重
    foreach ($b3 as $c3)
    {
    	   echo "<div><input type='checkbox' class='cc' name='kz3[]' value='{$c3}' />{$c3}</div>";
    }
    ?>
    请输入关键词<input type="text" name="keyword"   />
    <input type="submit" value="查询" />
    </form>
    
    <table border="1px">
      <tr>
       <td>id</td>
       <td>keyword</td>
       <td>area</td>
       <td>squaremeter</td>
       <td>rent</td>
       <td>renttype</td>
       <td>housetype</td>
       
      </tr>
    <?php
    $tj1="1=1";
    $tj2="1=1";
    $tj3="1=1";
    $tj4="1=1";
    $db=new mysqli("localhost","root","","1");
    !mysqli_connect_error() or die("连接错误");
    
    
    	if(!empty($_POST["kz1"]))
    	{   
    	    $attr1=$_POST["kz1"];
    		$pj1=implode("','",$attr1);
    		$tj1=" area in('{$pj1}') ";
    	}
    	if(!empty($_POST["kz2"]))
    	{
    		$attr2=$_POST["kz2"];
    		$pj2=implode("','",$attr2);
    		$tj2=" renttype in('{$pj2}') ";
    	}
    	if(!empty($_POST["kz3"]))
    	{   
    	    $attr3=$_POST["kz3"];
    		$pj3=implode("','",$attr3);
    		$tj3=" housetype in('{$pj3}')";
    	}
    	if(!empty($_POST["keyword"]))
    	{   
    	    $keyword=$_POST["keyword"];
    	    $tj4=" keyword like '%{$keyword}%'";
    	}
    	
    $tj="where {$tj1} and {$tj2} and {$tj3} and {$tj4}";
    $sql1="select * from house ".$tj;
    echo $sql1;
    $result1=$db->query($sql1);
    $attr1=$result1->fetch_all();
    foreach ($attr1 as $v)
    {
    	echo "
    	<tr>
    	<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>
    	";
    }
    ?>
    </table>
    </body>
    </html>
    <script type="text/jscript">
    function CheckAll(a,b)
    {
    	var xz = a.checked;
    	var ck = document.getElementsByClassName(b);
    	
    	for(var i=0; i<ck.length;i++)
    	{
    		ck[i].checked = xz;
    	}
    }
    </script>
    

     

    管理页面

    <!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 border="1px">
      <tr>
       <td>id</td>
       <td>keyword</td>
       <td>area</td>
       <td>squaremeter</td>
       <td>rent</td>
       <td>renttype</td>
       <td>housetype</td>
       <td>管理</td>
      </tr>
    
    <?php
    $db=new mysqli("localhost","root","","1");
    !mysqli_connect_error() or die("连接失败");
    $sql="select * from house ";
    $result=$db->query($sql);
    $attr=$result->fetch_all();
    foreach ($attr as $v)
    {
    	echo "
    	<tr>
    	<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='xiugai.php?id={$v[0]}'>修改</a><a onclick=" return confirm('确定删除')" href='shanchuchuli.php?id={$v[0]}'>删除</a></td>
    	</tr>
    	";
    }
    ?>
    </table>
    <a href="tianjia.php"><input type="button" value="添加" /></a>
    </body>
    </html>
    

     

    删除处理

    <?php
    $id=$_GET["id"];
    $db=new mysqli("localhost","root","","1");
    !mysqli_connect_error() or die("连接错误");
    $sql="delete from house where id='{$id}'";
    $result=$db->query($sql);
    if ($result)
    {
    	header("location:houtaixianshi.php");
    }
    else
    {
    	echo "连接失败";
    }
    

     添加页面

    <!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="tianjiachuli.php" method="post">
    <div>关键字<input type="text" name="keyword"/></div>
    <div>区域 <input type="text" name="area"/></div>
    <div>使用面积<input type="text" name="squaremeter"/></div>
    <div>租金<input name="rent" type="text" /></div>
    <div>租赁类型<input name="renttype" type="text"/></div>
    <div>房屋类型<input type="text" name="housetype"</div>
    <input type="submit" value="添加" />
    <input type="reset" value="取消"/>
    </form>
    
    </body>
    </html>
    

     

    添加管理

    <?php
    $keyword=$_POST["keyword"];
    $area=$_POST["area"];
    $squaremeter=$_POST["squaremeter"];
    $rent=$_POST["rent"];
    $renttype=$_POST["renttype"];
    $housetype=$_POST["housetype"];
    //造对象建连接
    $db=new mysqli("localhost","root","","1");
    //测试连接
    !mysqli_connect_error() or die("连接错误");
    //sql语句
    $sql="insert into house (keyword,area,squaremeter,rent,renttype,housetype)values('{$keyword}','{$area}','{$squaremeter}','{$rent}','{$renttype}','{$housetype}')";
    //运行sql
    $result=$db->query($sql);
    //监测插入是否成功
    if($result)
    {
    	header("location:houtaixianshi.php");
    }
    else
    {
    	echo"插入失败";
    }
    

     修改页面

    <!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
    $id=$_GET["id"];
    $db=new mysqli("localhost","root","","1");
    !mysqli_connect_error() or die("连接错误");
    $sql="select * from house where id='{$id}'";
    $result=$db->query($sql);
    $attr=$result->fetch_row();
    ?>
    <form action="xiugaichuli.php" method="post">
    <input type="hidden"  name="id" <?php echo "value='{$attr[0]}'";?>/>
    <div>关键字<input type="text"  name="keyword" <?php echo "value='{$attr[1]}'";?> /></div>
    <div>区域<input type="text" name="area" <?php echo "value='{$attr[2]}'"; ?>/></div>
    <div>使用面积<input type="text" name="squaremeter" <?php echo "value='{$attr[3]}'"; ?>/></div>
    <div>租金<input type="text" name="rent" <?php echo "value='{$attr[4]}'";?>/></div>
    <div>租赁类型<input type="text" name="renttype" <?php echo "value='{$attr[5]}'";?>/></div>
    <div>房屋类型<input type="text" name="housetype" <?php echo "value='{$attr[6]}'"; ?>/></div>
    <input type="submit" value="修改" />
    <input type="reset" value="取消" />
    </form>
    </body>
    </html>
    

     

    修改处理

    <?php
    $id=$_POST["id"];
    $keyword=$_POST["keyword"];
    $area=$_POST["area"];
    $squaremeter=$_POST["squaremeter"];
    $rent=$_POST["rent"];
    $renttype=$_POST["renttype"];
    $housetype=$_POST["housetype"];
    
    $db=new mysqli("localhost","root","","1");
    !mysqli_connect_error () or die("连接错误");
    $sql="update house set keyword='{$keyword}',area='{$area}',squaremeter='{$squaremeter}',rent='{$rent}',renttype='{$renttype}',housetype='{$housetype}' where id='{$id}'";
    $result=$db->query($sql);
    if ($result)
    {
    	header("location:houtaixianshi.php");
    }
    else
    {  
    echo "修改失败";
    }
    
  • 相关阅读:
    游戏中的View开发
    下载更新包,并且在任务栏提示进度.
    调用android非unbind的服务中的方法(不使用bindService启动的服务)
    判断android系统中Service是否在运行的方法
    如何从Activity中调用Service中的方法
    android官方文档---应用程序基础---服务的理解(app Component---services)
    怎么通过文件名的String,找到对应的资源ID
    疯狂Java之JDBC 笔记
    android应用将json数据打包在本地,进行读取的代码
    STL 堆的使用
  • 原文地址:https://www.cnblogs.com/zoubizhici/p/5598003.html
Copyright © 2011-2022 走看看