php读取最后一条数据 php获取数据库的某条信息

在PHP中使用SQL语句 怎么取出查询出来的最后一个数据?

select a.name name1,a.*,b.value,b.* from piwik_site a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and b.name='nb_visits' and a.idsite=b.idsite order by b.value desc

创新互联建站于2013年创立,是专业互联网技术服务公司,拥有项目成都做网站、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元昭平做网站,已为上家服务,为昭平各地企业和个人服务,联系电话:18982081108

如果页面显示的是这个语句,那么最后一个应该是select a.name name1,a.*,b.value,b.* from piwik_site

a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and

b.name='nb_visits' and a.idsite=b.idsite order by b.value asc limit 1

或者先执行一次select count(*) 拿到数量num,再select a.name name1,a.*,b.value,b.* from piwik_site

a,piwik_archive_numeric_2013_10 b where b.period in(1,2,3) and

b.name='nb_visits' and a.idsite=b.idsite order by b.value desc limit num-1,1

php怎么读取文件最后一行

首先你需要知道,你文件的最后一行大概有多少个字节。假如你的文件路径为C:/1.txt,最后一行大概有200个字节。那么你就这样写:

$handle=fopen("C:/1.txt","r");

fseek($handle,-200,SEEK_END);

$str=fgets($handle);

echo $str; //输出最后一行

fclose($handle);

PHP如何读取数据库记录中的最后一条数据?

您使用了limit 0,1就只有一条了,就是你要的最后一条。也许你问的问题没有说清楚


分享名称:php读取最后一条数据 php获取数据库的某条信息
标题URL:http://myzitong.com/article/hgcdpg.html