$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$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; case 3: $querystring.=" where type="".$type."" and price>200"; $showstr.="類型為".$type."并且价格大于200元間的所有數据"; break; } break; } } else { switch($price) { case 1: $querystring.=" where price$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$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$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$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$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 "
$showstr:
"; if (@mysql_num_rows($result)>0) { while (list($no,$type,$name,$qty,$price)=mysql_fetch_row($result)) { echo "
"; echo "
"; echo "
訂單編號
"; echo "
$no
"; echo "
"; echo "
"; echo "
類別
"; echo "
$type
"; echo "
"; echo "
"; echo "
配件
"; echo "
$name
"; echo "
"; echo "
"; echo "
數量
"; echo "
$qty
"; echo "
"; echo "
"; echo "
价格
"; echo "
$price
"; echo "
"; echo "
"; } } ?>
Statement:
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