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...