Multi-condition combination query (2)

Source: Internet
Author: User
Combined query by multiple conditions (2) This part is the result of the query after the actual use case is submitted. it is also the main part of the program generation:
$ Linkstr = mysql_connect ("localhost", "root", "sa ");
Mysql_select_db ("cx", $ linkstr );
$ Showstr = "Check Condition :";
$ Querystring = "select no, type, name, qty, price from orders ";
Switch ($ select1)
{
Case 1:
If (! Empty ($ no ))
{
Switch ($ select2)
{
Case 1:
$ Querystring. = "where no =". $ no;
$ Showstr. = "stand alone". $ no. "all data ";
Break;
Case 2:
Switch ($ price)
{
Case 1:
$ Querystring. = "where no =". $ no. "or price <50 ";
$ Showstr. = "simply". $ no. "or all data with a price less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where no =". $ no. "or price between 50 and 200 ";
$ Showstr. = "simply". $ no. "or all data with a price ranging from 50 to 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "or price> 200 ";
$ Showstr. = "simply". $ no. "or all data with a price greater than 200 RMB ";
Break;
}
Break;
Case 3:
Switch ($ price)
{
Case 1:
$ Querystring. = "where no =". $ no. "and price <50 ";
$ Showstr. = "all data with a price of less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where no =". $ no. "and price between 50 and 200 ";
$ Showstr. = "billing method". $ no. "all data with a price between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "and price> 200 ";
$ Showstr. = "all data with a price greater than 200 RMB ";
Break;
}
Break;
}
}
Else
{
If (! Empty ($ type ))
{
Switch ($ select2)
{
Case 1:
$ Querystring. = "where type =" ". $ type .""";
$ Showstr. = "type =". $ type. "all data ";
Break;
Case 2:
Switch ($ price)
{
Case 1:
$ Querystring. = "where type =" ". $ type." "or price <50 ";
$ Showstr. = "type:". $ type. "or all data with a price less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where type =" ". $ type." "or price between 50 and 200 ";
$ Showstr. = "type:". $ type. "or all data with a price between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where type =" ". $ type." "or price> 200 ";
$ Showstr. = "type =". $ type. "or all data with a price greater than 200 RMB ";
Break;
}
Break;
Case 3:
Switch ($ price)
{
Case 1:
$ Querystring. = "where type =" ". $ type." "and price <50 ";
$ Showstr. = "all data whose type is". $ type. "and whose price is less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where type =" ". $ type." "and price between 50 and 200 ";
$ Showstr. = "type =". $ type. "all data with a price between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where type =" ". $ type." "and price> 200 ";
$ Showstr. = "type =". $ type. "all data with a price greater than 200 RMB ";
Break;
}
Break;
}
}
Else
{
Switch ($ price)
{
Case 1:
$ Querystring. = "where price <50 ";
$ Showstr. = "all data whose price is less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where price between 50 & 200 ";
$ Showstr. = "all data whose prices are between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where price> 200 ";
$ Showstr. = "all data whose price is greater than 200 RMB ";
Break;
}
}
}
Break;
Case 2:
Switch ($ select2)
{
Case 1:
$ Querystring. = "where no =". $ no. "or type =" ". $ type .""";
$ Showstr. = "simply". $ no. "or". $ type. "all data ";
Break;
Case 2:
Switch ($ price)
{
Case 1:
$ Querystring. = "where no =". $ no. "or type =" ". $ type." "or price <50 ";
$ Showstr. = "simply". $ no. "or". $ type. "or all data with a price less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where no =". $ no. "or type =" ". $ type." "or price between 50 and 200 ";
$ Showstr. = "simply". $ no. "or". $ type. "or all data with a price between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "or type =" ". $ type." "or price> 200 ";
$ Showstr. = "simply". $ no. "or". $ type. "or all data with a price greater than 200 RMB ";
Break;
}
Break;
Case 3:
Switch ($ price)
{
Case 1:
$ Querystring. = "where no =". $ no. "or type =" ". $ type." "and price <50 ";
$ Showstr. = "billing method". $ no. "or". $ type. "for all data whose price is less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where no =". $ no. "or type =" ". $ type." "and price between 50 and 200 ";
$ Showstr. = "simply". $ no. "or". $ type. "all data with a price between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "or type =" ". $ type." "and price> 200 ";
$ Showstr. = "billing method". $ no. "or". $ type. "all data with a price greater than 200 RMB ";
Break;
}
Break;
}
Break;
Case 3:
Switch ($ select2)
{
Case 1:
$ Querystring. = "where no =". $ no. "and type =" ". $ type .""";
$ Showstr. = "statement". $ no. "and". $ type. "all data ";
Break;
Case 2:
Switch ($ price)
{
Case 1:
$ Querystring. = "where no =". $ no. "and type =" ". $ type." "or price <50 ";
$ Showstr. = "statement". $ no. "and". $ type. "or all data with a price less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where no =". $ no. "and type =" ". $ type." "or price between 50 and 200 ";
$ Showstr. = "statement". $ no. "and". $ type. "or all data with a price between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "and type =" ". $ type." "or price> 200 ";
$ Showstr. = "statement". $ no. "and". $ type. "or all data with a price greater than 200 RMB ";
Break;
}
Break;
Case 3:
Switch ($ price)
{
Case 1:
$ Querystring. = "where no =". $ no. "and type =" ". $ type." "and price <50 ";
$ Showstr. = "all data whose price is less than 50 yuan ";
Break;
Case 2:
$ Querystring. = "where no =". $ no. "and type =" ". $ type." "and price between 50 and 200 ";
$ Showstr. = "billing method". $ no. "and". $ type. "all data with a price between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "and type =" ". $ type." "and price> 200 ";
$ Showstr. = "billing method". $ no. "and". $ type. "all data with a price greater than 200 RMB ";
Break;
}
Break;
}
Break;
}
$ Result = mysql_query ($ querystring, $ linkstr );
Echo"

$ Showstr:


";
If (@ mysql_num_rows ($ result)> 0)
{
While (list ($ no, $ type, $ name, $ qty, $ price) = mysql_fetch_row ($ result ))
{
Echo"






















";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo"
Billing method$ No
Differences$ Type
Accessories$ Name
Data volume$ Qty
Price$ Price
";
}
}
?>

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.