02-19-2009, 11:44 PM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
Where are you having problems? To determine how many pages you need, you need 2 variables: the total number of "items" (be it entries in a database or just some records in an array), and the number of "items" you wish to display on a page. The number of resulting pages will be total_number_of_items / number_of_items_per_page. It's just simple math...nothing complicated.
Here's a simple hands-on example:
PHP Code:
$items = range(1, 25); $items_per_page = 10;
$number_of_items = count($items); $total_pages = ceil($number_of_items / $items_per_page); // we use ceil because if we have 11 entries, with 10 entries per page, that means there will be 2 pages
echo $total_pages; // this will give 3
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|