Reputation: 1690
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?
Upvotes: 2
Views: 6736
Reputation: 1
If you find proper solution of the pagination then you can use this
TotalPage=(TotalRecords/PageSize)+((TotalRecords%PageSize)>0)?1:0)
Upvotes: 0
Reputation: 350
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
Upvotes: 1
Reputation: 18859
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.
Upvotes: 3