Multi-condition combined query (2) _ PHP Tutorial

Source: Internet
Author: User
Multi-condition combination query (2 ). This part is the query result after the user submits, and is also the main part of the program code :? LinkstrMySQL (the best combination with PHP) _ connect (localhost, root, sa); MySQ is followed by the query results after the user submits and is also the main part of the program code:
$ Linkstr = MySQL (the best combination with PHP) _ connect ("localhost", "root", "sa ");
MySQL (best combination with PHP) _ select_db ("cx", $ linkstr );
$ Showstr = "the query condition is :";
$ 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. = "order is". $ no. "all data ";
Break;
Case 2:
Switch ($ price)
{
Case 1:
$ Querystring. = "where no =". $ no. "or price <50 ";
$ Showstr. = "The order is". $ 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. = "The order is". $ no. "or all data with a price ranging from 50 to 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "or price> 200 ";
$ Showstr. = "The order is". $ 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 an order of". $ no. "and a price of less than 50 RMB ";
Break;
Case 2:
$ Querystring. = "where no =". $ no. "and price between 50 and 200 ";
$ Showstr. = "The order is". $ no. "and the price is between 50 and 200 RMB ";
Break;
Case 3:
$ Querystring. = "where no =". $ no. "and price> 200 ";
$ Showstr. = "The order is". $ no. "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. = "The type is". $ type. "or all data with a price ranging from 50 to 200 RMB ";
Break;
Case 3:
$ Querystring. = "where type =" ". $ type." "or price> 200 ";
$ Showstr. = "The type is". $ 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. = "The type is". $ type. "and the price is between 50 and 200 RMB ";
Break;

Why :? Linkstr = MySQL (the best combination with PHP) _ connect ("localhost", "root", "sa"); MySQ...

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.