开发者

pagination with php with a possible infinite limit

开发者 https://www.devze.com 2023-04-03 03:18 出处:网络
I know how to create pagination with php if I have 25 results with 5 results each page, but what about if the limit number can change in the hundreds everyday? How can I write something where the php

I know how to create pagination with php if I have 25 results with 5 results each page, but what about if the limit number can change in the hundreds everyday? How can I write something where the php itself will create more pages if the 开发者_Go百科row count itself changes?


usually pagination is made in two steps:

  • query to count the number of records
  • unsig the prevoius query, create the query using LIMIT to retrieve the current page

So i don't see the problem o_O, if tomorrow the number of elements change then the first query would return a different result.. and you wont have problems with the pagination

Later, if you want to improve performance you could set a cache system for the count query.

Hope this helps

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号