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> echo($color."");<br> echo($caizhi."");<br> echo($style."");<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><div><?php echo $row['psp_name'];?></div></td><br> }while($row=mysql_fetch_array($rows));<br> }<br> else<br> {?><br><td><div>没有符合条件的信息,请重新定义搜索条件!</div></td><br><br> }<br> ?>
这个代码有神马问题?为什么会报错:warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /data/home/hmu069081/htdocs/products/get_post.php on line 37
且没有符合条件的信息,可是我选的条件明明是有记录的
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!











