怎么算出一条记录在分页中会是第几页
现在有这个一个需求,要知道评论的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 protected]+1, ceiling(@line/$pagesize) as page FROM tbl_name) t where id=$id
Statement: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