多重條件組合查詢(二)
来源:互联网 发布:backbone.js 编辑:程序博客网 时间:2024/06/06 23:23
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<?
$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>";
}
}
?>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
接一來這部分是實現用戶提交之后的查詢結果,也是程序代碼的主体部份: <?
$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>";
}
}
?>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 多重條件組合查詢(二)
- 多重條件組合查詢(一)
- 并查集 合集
- 合服测试(二)
- Ubuntu命令合集(二)
- 2009年初 博合相关的几件事情
- DataGridView控件用法合集(二)
- DataGridView控件用法合集(二)
- DataGridView控件用法合集(二)
- DataGridView控件用法合集(二)
- 关于C#中集合和数组(二)
- 编程作业 第一、二章【合】
- java中集合总结(二)
- Python 练手程序合集(二)
- 【codevs】基础合集(二)
- Java中集合(二)Vector
- 算法合集——并查集union-find
- NLP 工具包 大调查 自然语言处理工具包合集
- PHP使用者状态管理功能的应用
- C#2.0 Specification(泛型一)
- 模拟OICQ的实现思路和核心程序(三)
- C# 2.0 Specification (泛型三)
- 一个显示天气预报的程序
- 多重條件組合查詢(二)
- 文章推荐系统(三)
- 在ASP.NET中动态生成图形(转)
- 多重條件組合查詢(一)
- 一个SDK里做聊天室的例子(2)
- 文章推荐系统(二)
- ms--help
- 在PHP中利用XML技术构造远程服务(下)
- 续