开发者

Whats the formula to get the page numbers for pagination?

开发者 https://www.devze.com 2023-03-08 05:28 出处:网络
This question is relevant for a lightweight pagination script I am busy writing. I have the total items and the page 开发者_如何转开发limit for every page. for example 15 items in total but I would l

This question is relevant for a lightweight pagination script I am busy writing.

I have the total items and the page 开发者_如何转开发limit for every page. for example 15 items in total but I would like to paginate on 10. This means there are 2 pages. How do I get to that using a formula?

I am using ceil( $total / $page_limit ) at the moment is that right?


yes, it's right. 15/10 = 1.5. that ceiled is 2


I am using ceil( $total / $page_limit ) at the moment is that right?

Yes, it is. If there is nothing to round (e.g. if the outcome is not a float) it will simply return the outcome. If the outcome is a float, it will round it up (next highest integer value), so you'll have one page with less items than the rest, but that shouldn't be an issue.


I am not sure where you are at the moment with a code, but you need to do little more to create a pagination process, i would suggest to google some simple php pagination code and use that in your code.

check this one for help! http://php.about.com/od/phpwithmysql/ss/php_pagination.htm

0

精彩评论

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