PHP Multi-Conditional overlay Query
Header ("Content-type:text/html;charset=utf-8");
Include (".. /manage/include/function.php ");
$brand =substr ($_post["brand"],0,strlen ($_post["brand")-1);
$color =substr ($_post["Color"],0,strlen ($_post["Color"])-1);
$caizhi =$_post["Caizhi"];
$style =$_post["Style"];
$kucun =$_post["Kucun"];
Echo ($brand. "
");
Echo ($color. "
");
Echo ($caizhi. "
");
Echo ($style. "
");
Echo ($kucun);
$q = "SELECT * from Pros_pro where (1=1)";
if ($brand!=null) {
$q = $q + "and Psp_brand in (". $brand. ")";
}
if ($color!=null) {
$q = $q + "and Psp_color in (". $color. ")";
}
if ($caizhi!=null) {
$q = $q + "and psp_caizhi=". $caizhi. "'";
}
if ($style!=null) {
$q = $q + "and psp_style=". $style. "'";
}
if ($kucun!=null) {
$q = $q + "ORDER by psp_stock Desc";
}else
{
$q = $q + "ORDER by psp_id Desc";
}
$rows =query ($q);
if ($row =mysql_fetch_array ($rows))
{
do{
?>
}
Else
{?>
There is no qualifying information, please redefine the search criteria!
}
?>
Does this code have a problem with horses? Why error: Warning:mysql_fetch_array () expects parameter 1 to be resource, boolean given In/data/home/hmu069081/htdocs/prod Ucts/get_post.php on line 37
And there are no eligible information, but the conditions I chose are clearly recorded.
------Solution--------------------
Put all shapes as
$q = $q + "and Psp_brand in (". $brand. ")";
Such a statement, which is shaped like this
$q = $q. "And Psp_brand in (". $brand. ")";
Or
$q. = "and Psp_brand in (". $brand. ")";