Php multi-condition query

Source: Internet
Author: User
Php multi-condition superimposed query & lt ;? Header ("Content-Type: text/html; charset = utf-8"); include (".. /manage/include/function. php "); $ brand = substr ($ _ POST [" brand "], 0, strlen ($ _ POST php multi-condition superposition 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 matching information. Please Redefine the search criteria!
}
?>


What's wrong with this code? Why error: Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in/data/home/hmu069081/htdocs/products/get_post.php on line 37
There is no matching information, but the selected condition is clearly recorded: More

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.