Home > Backend Development > PHP Tutorial > Multiple condition combination query (2)_PHP tutorial

Multiple condition combination query (2)_PHP tutorial

WBOY
Release: 2016-07-13 17:31:38
Original
965 people have browsed it

Next, this part is to implement the query results after the user submits it, which is also the main part of the program code:
$linkstr=MySQL(The best combination with PHP) _connect("localhost","root","sa");
MySQL(The 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;
$ showsr.="The order is ".$no."All data"; .=" where no=".$no." or price<50";
$showstr.="All data where the order is ".$no." or the price is less than 50 yuan";
break;
case 2:
$querystring.=" where no=".$no." or price between 50 and 200";
$showstr.="The order is ".$no." or price between 50 and 200"; All data between 50 and 200 yuan";
break;
case 3:
$querystring.=" where no=".$no." or price>200";
$showstr .="All data where the order is ".$no." or the price is greater than 200 yuan";
break;
}
break;
case 3:
switch($price)
{
case 1:
$querystring.=" where no=".$no." and price<50";
$showstr.="The order is ".$no." and All data with a price less than 50 yuan";
break;
case 2:
$querystring.=" where no=".$no." and price between 50 and 200";
$ showsr.="All data where the order is ".$no." and the price is between 50 and 200 yuan";
break;
case 3:
$querystring.=" where no=". $no." and price>200";
$showstr.="All data between the order ".$no." and the price greater than 200 yuan";
break;
}
break ;
}
}
else
{
if (!empty($type))
{
switch($select2)
{
case 1 :
$querystring.=" where type="".$type."" ";
$showstr.=" All data of type ".$type.";
break;
case 2:
switch($price)
{
case 1:
$querystring.=" where type="".$type."" or price<50";
$ showstr.="All data with type ".$type." or price less than 50 yuan";
break;
case 2:
$querystring.=" where type="".$type ."" or price between 50 and 200";
$showstr.="All data of type ".$type." or price between 50 and 200 yuan";
break;
case 3:
$querystring.=" where type="".$type."" or price>200";
$showstr.=" where type is ".$type." or price is greater than 200 yuan All data";  
break;  
}  
break; where type="".$type."" and price<50";
$showstr.="All data with type ".$type." and price less than 50 yuan";
break;
case 2:
$querystring.=" where type="".$type."" and price between 50 and 200";
$showstr.=" where type="".$type."" and price between 50 and 200"; All data between 50 and 200 yuan";
break;



http://www.bkjia.com/PHPjc/508962.html

www.bkjia.com

true

http: //www.bkjia.com/PHPjc/508962.html

TechArticle

The next part is to implement the query results after the user submits it, and it is also the main part of the program code: ? linksstr =MySQL (the best combination with PHP) _connect("localhost","root","sa"); MySQ...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template