想象我们使用分页来分割和显示像这样的mysql结果,
按自动inceremental ID和日期排序:
SELECT name FROM members ORDER BY id DESC,date DESC LIMIT $start,$len
想象我们使用分页来分割和显示像这样的mysql结果,
按自动inceremental ID和日期排序:
SELECT name FROM members ORDER BY id DESC,date DESC LIMIT $start,$len
select count(*) as total from members;
在记录列表中找到行成员“x”的编号
select count(*) oneLess from members where id < (select id from members where name='x');
上面的查询返回一个来自x的记录号.即’x’是1Less 1
现在计算页码.
$asc_page_no = floor((($oneLess+1)/$total)*$len);
$total_pages = floor($total/$len);
$page_no = $total_pages - $asc_page_no; //reverse the page looking direction
然后计算$start
$start = $page_no * $len;