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
精彩评论