php多条件叠加查询
<?<br />
header("Content-Type:text/html;charset=utf-8");<br />
include("../manage/include/function.php");<br />
$brand=substr($_POST["brand"],0,strlen($_POST["brand"])-1); <br />
$color=substr($_POST["color"],0,strlen($_POST["color"])-1); <br />
$caizhi=$_POST["caizhi"];<br />
$style=$_POST["style"];<br />
$kucun=$_POST["kucun"];<br />
echo($brand."</br>");<br />
echo($color."</br>");<br />
echo($caizhi."</br>");<br />
echo($style."</br>");<br />
echo($kucun);<br />
<br />
$q="select * from pros_pro where (1=1)";<br />
if($brand!=null){<br />
$q=$q+"and psp_brand in(".$brand.")";<br />
}<br />
if($color!=null){<br />
$q=$q+"and psp_color in(".$color.")";<br />
}<br />
if($caizhi!=null){<br />
$q=$q+"and psp_caizhi='".$caizhi."'";<br />
}<br />
if($style!=null){<br />
$q=$q+"and psp_style='".$style."'";<br />
}<br />
if($kucun!=null){<br />
$q=$q+"order by psp_stock desc";<br />
}else<br />
{<br />
$q=$q+"order by psp_id desc";<br />
}<br />
<br />
<br />
$rows=query($q);<br />
if($row=mysql_fetch_array($rows))<br />
{<br />
do{<br />
?><br />
<td align='right'><div align='center'><?php echo $row['psp_name'];?></div></td><br />
<? }while($row=mysql_fetch_array($rows));<br />
}<br />
else<br />
{?><br />
<td align='right'><div align='center'>没有符合条件的信息,请重新定义搜索条件!</div></td><br />
<?<br />
}<br />
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号