最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

多重條件組合查詢(二)

来源:动视网 责编:小采 时间:2020-11-27 19:01:49
文档

多重條件組合查詢(二)

多重條件組合查詢(二):接一來這部分是實現用戶提交之后的查詢結果,也是程序代碼的主体部份: < $linkstr=mysql_connect("localhost","root","sa"); mysql_select_db("cx",$linkstr); $sh
推荐度:
导读多重條件組合查詢(二):接一來這部分是實現用戶提交之后的查詢結果,也是程序代碼的主体部份: < $linkstr=mysql_connect("localhost","root","sa"); mysql_select_db("cx",$linkstr); $sh


接一來這部分是實現用戶提交之后的查詢結果,也是程序代碼的主体部份:  
<?  
$linkstr=mysql_connect("localhost","root","sa");  
mysql_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<50";  
$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<50";  
$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<50";  
$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<50";  
$showstr.="類型為".$type."并且价格少于50元的所有數据";  
break;  
case 2:  
$querystring.=" where type="".$type."" and price between 50 and 200";  
$showstr.="類型為".$type."并且价格介于50到200元間的所有數据";  
break;  
case 3:  
$querystring.=" where type="".$type."" and price>200";  
$showstr.="類型為".$type."并且价格大于200元間的所有數据";  
break;  
}  
break;  
}  
}  
else  
{  
switch($price)  
{  
case 1:  
$querystring.=" where price<50";  
$showstr.="价格少于50元的所有數据";  
break;  
case 2:  
$querystring.=" where price between 50 and 200";  
$showstr.="价格介于50到200元間的所有數据";  
break;  
case 3:  
$querystring.=" where price>200";  
$showstr.="价格大于200元間的所有數据";  
break;  
}  
}  
}  
break;  
case 2:  
switch($select2)  
{  
case 1:  
$querystring.=" where no=".$no." or type="".$type.""";  
$showstr.="訂單為".$no."或者類別為".$type."所有數据";  
break;  
case 2:  
switch($price)  
{  
case 1:  
$querystring.=" where no=".$no." or type="".$type."" or price<50 ";  
$showstr.="訂單為".$no."或者類別為".$type."或者价格少于50元的所有數据";  
break;  
case 2:  
$querystring.=" where no=".$no." or type="".$type."" or price between 50 and 200";  
$showstr.="訂單為".$no."或者類別為".$type."或者价格介于50到200元間的所有數据";  
break;  
case 3:  
$querystring.=" where no=".$no."or type="".$type."" or price>200";  
$showstr.="訂單為".$no."或者類別為".$type."或者价格大于200元間的所有數据";  
break;  
}  
break;  
case 3:  
switch($price)  
{  
case 1:  
$querystring.=" where no=".$no." or type="".$type."" and price<50 ";  
$showstr.="訂單為".$no."或者類別為".$type."并且价格少于50元的所有數据";  
break;  
case 2:  
$querystring.=" where no=".$no." or type="".$type."" and price between 50 and 200";  
$showstr.="訂單為".$no."或者類別為".$type."并且价格介于50到200元間的所有數据";  
break;  
case 3:  
$querystring.=" where no=".$no."or type="".$type."" and price>200";  
$showstr.="訂單為".$no."或者類別為".$type."并且价格大于200元間的所有數据";  
break;  
}  
break;  
}  
break;  
case 3:  
switch($select2)  
{  
case 1:  
$querystring.=" where no=".$no." and type="".$type.""";  
$showstr.="訂單為".$no."并且類別為".$type."所有數据";  
break;  
case 2:  
switch($price)  
{  
case 1:  
$querystring.=" where no=".$no." and type="".$type."" or price<50 ";  
$showstr.="訂單為".$no."并且類別為".$type."或者价格少于50元的所有數据";  
break;  
case 2:  
$querystring.=" where no=".$no." and type="".$type."" or price between 50 and 200";  
$showstr.="訂單為".$no."并且類別為".$type."或者价格介于50到200元間的所有數据";  
break;  
case 3:  
$querystring.=" where no=".$no."and type="".$type."" or price>200";  
$showstr.="訂單為".$no."并且類別為".$type."或者价格大于200元間的所有數据";  
break;  
}  
break;  
case 3:  
switch($price)  
{  
case 1:  
$querystring.=" where no=".$no." and type="".$type."" and price<50 ";  
$showstr.="訂單為".$no."并且類別為".$type."并且价格少于50元的所有數据";  
break;  
case 2:  
$querystring.=" where no=".$no." and type="".$type."" and price between 50 and 200";  
$showstr.="訂單為".$no."并且類別為".$type."并且价格介于50到200元間的所有數据";  
break;  
case 3:  
$querystring.=" where no=".$no."and type="".$type."" and price>200";  
$showstr.="訂單為".$no."并且類別為".$type."并且价格大于200元間的所有數据";  
break;  
}  
break;  
}  
break;  
}  
$result=mysql_query($querystring,$linkstr);  
echo "<p>$showstr:<p>  
";  
if (@mysql_num_rows($result)>0)  
{  
while (list($no,$type,$name,$qty,$price)=mysql_fetch_row($result))  
{  
echo "<table align="center">";  
echo "<tr>";  
echo "<td>訂單編號</td>";  
echo "<td>$no</td>";  
echo "</tr>";  
echo "<tr>";  
echo "<td>類別</td>";  
echo "<td>$type</td>";  
echo "</tr>";  
echo "<tr>";  
echo "<td>配件</td>";  
echo "<td>$name</td>";  
echo "</tr>";  
echo "<tr>";  
echo "<td>數量</td>";  
echo "<td>$qty</td>";  
echo "</tr>";  
echo "<tr>";  
echo "<td>价格</td>";  
echo "<td>$price</td>";  
echo "</tr>";  
echo "</table>";  
}  
}  
?>  

文档

多重條件組合查詢(二)

多重條件組合查詢(二):接一來這部分是實現用戶提交之后的查詢結果,也是程序代碼的主体部份: < $linkstr=mysql_connect("localhost","root","sa"); mysql_select_db("cx",$linkstr); $sh
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top