您好,欢迎访问一九零五行业门户网

多重条件组合查询(二)_PHP教程

接一来这部分是实现用户提交之后的查询结果,也是程序代码的主体部份:
$linkstr=mysql(和php搭配之最佳组合)_connect(localhost,root,sa);  
mysql(和php搭配之最佳组合)_select_db(cx,$linkstr);  
$showstr=查询条件为:;  
$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.=订单为.$no.所有数据;  
break;  
case 2:  
switch($price)  
{  
case 1:  
$querystring.= where no=.$no. or price$showstr.=订单为.$no.或者价格少于50元的所有数据;  
break;  
case 2:  
$querystring.= where no=.$no. or price between 50 and 200;  
$showstr.=订单为.$no.或者价格介于50到200元间的所有数据;  
break;  
case 3:  
$querystring.= where no=.$no. or price>200;  
$showstr.=订单为.$no.或者价格大于200元间的所有数据;  
break;  
}  
break;  
case 3:  
switch($price)  
{  
case 1:  
$querystring.= where no=.$no. and price$showstr.=订单为.$no.并且价格少于50元的所有数据;  
break;  
case 2:  
$querystring.= where no=.$no. and price between 50 and 200;  
$showstr.=订单为.$no.并且价格介于50到200元间的所有数据;  
break;  
case 3:  
$querystring.= where no=.$no. and price>200;  
$showstr.=订单为.$no.并且价格大于200元间的所有数据;  
break;  
}  
break;  
}  
}  
else  
{  
if (!empty($type))  
{  
switch($select2)  
{  
case 1:  
$querystring.= where type=.$type. ;  
$showstr.= 类型为.$type.所有数据;  
break;  
case 2:  
switch($price)  
{  
case 1:  
$querystring.= where type=.$type. or price$showstr.=类型为.$type.或者价格少于50元的所有数据;  
break;  
case 2:  
$querystring.= where type=.$type. or price between 50 and 200;  
$showstr.=类型为.$type.或者价格介于50到200元间的所有数据;  
break;  
case 3:  
$querystring.= where type=.$type. or price>200;  
$showstr.=类型为.$type.或者价格大于200元间的所有数据;  
break;  
}  
break;  
case 3:  
switch($price)  
{  
case 1:  
$querystring.= where type=.$type. and price$showstr.=类型为.$type.并且价格少于50元的所有数据;  
break;  
case 2:  
$querystring.= where type=.$type. and price between 50 and 200;  
$showstr.=类型为.$type.并且价格介于50到200元间的所有数据;  
break;
http://www.bkjia.com/phpjc/508962.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/508962.htmltecharticle接一来这部分是实现用户提交之后的查询结果,也是程序代码的主体部份: ? linkstr=mysql (和php搭配之最佳组合) _connect(localhost,root,sa); mysq...
其它类似信息

推荐信息