租房子-----多选题

	<?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-08-27 22:51:17

租房子-----多选题的相关文章

PHP-----练习-------租房子-----增删改查,多条件查询

练习-------租房子-----增删改查,多条件 一 .题目要求: 二 .做法: [1]建立数据库 [2]封装类文件------DBDA.class.php 1 <?php 2 class DBDA 3 { 4 public $fuwuqi="localhost"; //服务器地址 5 public $yonghuming="root";//用户名 6 public $mima="";//密码 7 8 public $dbconnect;

练习题投票和租房子

一:投票,连个页面都引用了DBDA封装类 <!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

增删改查租房子练习题

租房子练习题:重要颜色 1.模仿get传值到处理php页面:<a href='shanchu.php?c={$v[0]}' onclick=\"return confirm('确定删除吗?')\">删除</a> 2.删除页面显示确定删除提示框:<a href='shanchu.php?c={$v[0]}' onclick=\"return confirm('确定删除吗?')\">删除</a> 主页面: <body

php封装+租房子练习题

第一个页面DBDA.class.php <?php class DBDA { public $host = "localhost"; public $uid = "root"; public $pwd = "root"; public $dbname = "dbname"; public function Query($sql,$type=1)//两个参数,第二个参数代表默认值 { $db = new MySQLi($t

11月6日上午PHP练习《租房子》解析

一.题目要求 二.题目做法 1.建立数据库 2.封装类文件 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 public $yonghuming="root";//用户名 public $mima="";//密码 public $dbconnect;//连接对象 //操作数据库的方法 //$sql代表需要执行的SQL语句 //$type代表SQL语句的类型,1代表查询,2代表增删

php之租房子练习

一.题目要求 二.题目做法 1.建立数据库 2.封装类文件 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 public $yonghuming="root";//用户名 public $mima="";//密码 public $dbconnect;//连接对象 //操作数据库的方法 //$sql代表需要执行的SQL语句 //$type代表SQL语句的类型,1代表查询,2代表增删

php租房子批量搜索例题

租房子例题是用来练习多条件查询以及批量选择的典型例题,题面是这样的: 首先要分别建立区域.租赁类型.房屋类型的复选界面,遍历出所有数据,这里用无边框表格创建: <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td>区域:<input type="checkbox" name="qx" onclic

php练习 租房子

一.题目要求 做法 2.封装类文件 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 public $yonghuming="root";//用户名 public $mima="";//密码 public $dbconnect;//连接对象 //操作数据库的方法 //$sql代表需要执行的SQL语句 //$type代表SQL语句的类型,1代表查询,2代表增删改 //$shujuku

PHP 练习3:租房子

一.题目要求 二.题目做法 1.建立数据库 2.封装类文件 <?php class DBDA { public $fuwuqi="localhost"; //服务器地址 public $yonghuming="root";//用户名 public $mima="";//密码 public $dbconnect;//连接对象 //操作数据库的方法 //$sql代表需要执行的SQL语句 //$type代表SQL语句的类型,1代表查询,2代表增删