用PHP查询数据库,但数据重复显示,如何能让数据不重复如下图:
自编号0193 06:25:35状态显示完成,但11:25:35也显示完成,如何能让同一版本号数据只显示最新的,
网页代码如下:
nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
if($_REQUEST['submit']!="")
{
$link=mysql_connect("127.0.0.1","root","12345678");
if(!$link) echo "没有连接成功!";
else echo "连接成功!";
mysql_select_db("busap", $link); //选择数据库
//控制查询条件
$q = "SELECT * FROM research where banben like '%{$_REQUEST['banben']}%' AND linename like '%{$_REQUEST['xianlu']}%' AND zhuangtai like '%{$_REQUEST['zhuangtai']}%' order by busname asc";
// mysql_query("SET NAMES GB2312"); //防止乱码
$rs = mysql_query($q); //获取数据集
$assoc= mysql_num_rows($rs);///影响的行数 , 原来用了mysql_fetch_assoc
echo "$assoc";
$row=mysql_fetch_array($rs); //只需要补充回这一行.
if(!$rs){die("Valid result!");}
}
?>
线路 | 中心编号 | 线路 | 车辆自编号 | 传输方式 | 媒体版本 | 日期 | 时间 | 状态 |
回复讨论(解决方案)
加个标识列,显示过的数据,更新为1.未显示的为0,查询时,只查询标识为0的数据。
写个判断就好了,版本号相同时,取最大时间的记录
能给个详细判断代码吗,本人小白,初学者
试试
$q = "SELECT *,max(媒体版本) FROM research where banben like '%{$_REQUEST['banben']}%' AND linename like '%{$_REQUEST['xianlu']}%' AND zhuangtai like '%{$_REQUEST['zhuangtai']}%' group by 媒体版本 order by max(媒体版本) busname asc";
就是取媒体版本的最大值,然后显示
这不是很简单吗?
可以使用max函数.

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 Linux new version
SublimeText3 Linux latest version

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
