PHP SQL Server
$wd1=$_POST['wd1']; //原来是这样sql="select * from xxx where pr_id like '%". $wd1."%'";
//**********************************************************
//现在要做成假如输入:123 王
//sql="select * from xxx where pr_id like '%123%' and name like '%王%'";
//等等就像上面这样,用户输入的条件可能是多个如:123 王 男或者一个
wd1=$_POST['wd1']; //现在接收input数据,
$split_dir = split ('[ ]',$wd1);//我想着转换成数组
//然后sql server2000语句不知道咋写了,不知道我的意思表达明白了没有,我想表达清楚,求解答思路,
sql="???";
回复讨论(解决方案)
真心,不会了啊。。求教。。提前感谢各位!!
$where = "1=1";$arr = array('col1','col2','col3');foreach($split_dir AS $key=>$val){ $where .= " AND ".$arr[$key]." LIKE '%".$val."%' ";}
$arr是需要在where里面出现的字段名,当然了,安全方面的事你自己控制。
这个只是个大概的思路,这个很显然不够完善,因为别人可能输入 123 男 王 或者增加输入之间的空格,这个都需要你自己去控制
嗯。。谢谢我试试
嘿嘿好了。。。。。我是这样写的
$wd1=$_POST['wd1'];
$split_dir = split ('[ ]',$wd1);
$arr = array('编码','名称','类别','型号');
$where2=" ";
for($m=0;$m
{
for($n=0;$n
if($n==(count($arr)-1)){
$where2=$where2.$arr[$n]." like '%".$split_dir[$m]."%'";
}else{
$where2=$where2.$arr[$n]." like '%".$split_dir[$m]."%' or ";
}
}
$where2=$where2." ";
}else{
for($n=0;$n
if($n==(count($arr)-1)){
$where2=$where2.$arr[$n]." like '%".$split_dir[$m]."%'";
}else{
$where2=$where2.$arr[$n]." like '%".$split_dir[$m]."%' or ";
}
}
$where2=$where2." ) and ( ";
}
}

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools
