Home > Backend Development > PHP Tutorial > 如何算出一条记录在分页中会是第几页

如何算出一条记录在分页中会是第几页

WBOY
Release: 2016-06-13 11:49:50
Original
1512 people have browsed it

怎么算出一条记录在分页中会是第几页
现在有这个一个需求,要知道评论的id是在评论表里的第几页,不知道这样能不能实现。排序方式不一定是按id排序的。。
------解决方案--------------------
可以实现!~~
mysql数据查询的时候增加个行号  (@rownum:[email protected]+1) as rowno
------解决方案--------------------

本帖最后由 xuzuning 于 2014-02-21 17:00:42 编辑
set @line:=0;<br />select * from <br /> ( SELECT id, @line:[email&#160;protected]+1, ceiling(@line/$pagesize) as page FROM tbl_name) t where id=$id
Copy after login
 
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template