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:
$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.
I had a hard time myself before. Then I created my own independant paginationclass(meaning it isn't locked to pagination of dbresults, but it can paginate anything), and once I saw - and worked with - the formulas, it all became clear.