接一來這部分是實現用戶提交之后的查詢結果,也是程序代碼的主体部份:
$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 "
訂單編號 | ";$no | ";
類別 | ";$type | ";
配件 | ";$name | ";
數量 | ";$qty | ";
价格 | ";$price | ";
}
}
?>

tomakephpapplicationsfaster,关注台词:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

到ImprovephPapplicationspeed,关注台词:1)启用opcodeCachingwithapCutoredUcescriptexecutiontime.2)实现databasequerycachingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandredececonnection.4 limitsclection.4.4

依赖注入(DI)通过显式传递依赖关系,显着提升了PHP代码的可测试性。 1)DI解耦类与具体实现,使测试和维护更灵活。 2)三种类型中,构造函数注入明确表达依赖,保持状态一致。 3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

databasequeryOptimizationinphpinvolVolVOLVESEVERSEVERSTRATEMIESOENHANCEPERANCE.1)SELECTONLYNLYNESSERSAYCOLUMNSTORMONTOUMTOUNSOUDSATATATATATATATATATATRANSFER.3)

phpisusedforsenderemailsduetoitsbuilt-inmail()函数andsupportiveLibrariesLikePhpMailerandSwiftMailer.1)usethemail()functionforbasicemails,butithasimails.2)butithasimimitations.2)

PHP性能瓶颈可以通过以下步骤解决:1)使用Xdebug或Blackfire进行性能分析,找出问题所在;2)优化数据库查询并使用缓存,如APCu;3)使用array_filter等高效函数优化数组操作;4)配置OPcache进行字节码缓存;5)优化前端,如减少HTTP请求和优化图片;6)持续监控和优化性能。通过这些方法,可以显着提升PHP应用的性能。

依赖性注射(DI)InphpisadesignPatternthatManages和ReducesClassDeptions,增强量产生性,可验证性和Maintainability.itallowspasspassingDepentenciesLikEdenceSeconnectionSeconnectionStoclasseconnectionStoclasseSasasasasareTers,interitationApertatingAeseritatingEaseTestingEasingEaseTeStingEasingAndScalability。

cachingimprovesphpermenceByStorcyResultSofComputationsorqucrouctationsorquctationsorquickretrieval,reducingServerLoadAndenHancingResponsetimes.feftectivestrategiesinclude:1)opcodecaching,whereStoresCompiledSinmememorytssinmemorytoskipcompliation; 2)datacaching datacachingsingMemccachingmcachingmcachings


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver Mac版
视觉化网页开发工具

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

SublimeText3汉化版
中文版,非常好用

SublimeText3 英文版
推荐:为Win版本,支持代码提示!