php简单多条件查询语句,php多条件查询

需要查询的表格

b4ea0052c426c407915f829b8f3cef00.png

代码:

无标题文档

require "Wang.class.php"; //调用类

$db= new Wang();

$keyword="";

$tj1 = " 1=1 ";

$tj2 = " 1=1 ";

$tj3 = " 1=1 ";

$tj4 = " 1=1 ";

if(!empty($_POST["area"]))

{

$area=$_POST["area"];

$str1 = implode("','",$area);

$tj1 = " area in ('{$str1}') ";

}

if(!empty($_POST["renttype"]))

{

$renttype =$_POST["renttype"];

$str2 = implode("','",$renttype);

$tj2 = " renttype in ('{$str2}') ";

}

if(!empty($_POST["housetype"]))

{

$housetype =$_POST["housetype"];

$str3 = implode("','",$housetype);

$tj3 = " housetype in ('{$str3}') ";

}

if(!empty($_POST["keyword"]))

{

$keyword=$_POST["keyword"];

$tj4 = " keyword like '%{$keyword}%' ";

}

?>

区    域:全选

$sql = "select distinct area from house";

$arr = $db->query($sql);

foreach($arr as $v)

{

echo "

{$v[0]}";

}

?>

租赁类型: 全选

$sqlr = "select distinct renttype from house";

$arr1 = $db->query($sqlr);

foreach($arr1 as $r)

{

echo "

{$r[0]}";

}

?>

房屋类型:全选

$sqlh = "select distinct housetype from house";

$arr2 = $db->query($sqlh);

foreach($arr2 as $h)

{

echo "

{$h[0]}";

}

?>

关 键 字:

关键字区域面积租金(每月)租赁类型房屋类型

$tj =" {$tj1} and {$tj2} and {$tj3} and {$tj4} ";

$sqly = "select * from house where ".$tj;

$arry = $db->query($sqly,1);

foreach($arry as $y)

{

$str = str_replace($keyword,"{$keyword}",$y[1]);

echo "

{$str}{$y[2]}{$y[3]}{$y[4]}{$y[5]}{$y[6]}";

}

?>

function quanxuan(a,qy)

{

var ck = document.getElementsByClassName(qy);

if(a.checked)

{

for(var i=0;i

{

ck[i].setAttribute("checked","checked");

}

}

else

{

for(var i=0;i

{

ck[i].removeAttribute("checked");

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值