Page 1 of 1

Pagination Problem

Posted: Tue May 16, 2006 3:27 am
by Benjamin
I am a little bit stumped on this one. I am creating pages that allow a visitor to view search results with 2 different views.

The first view, say Detailed view shows 16 results per page. The second view, Standard view, shows 36 results per page.

When I calculate what record to start on I use the following code.

Code: Select all

$NumberOfResults = mysql_num_rows($Execute);
$StartingRecord       = ($NumberOfRecordsDisplayedPerPage * $CurrentPage) - $NumberOfRecordsDisplayedPerPage;
The problem I am having is that if you are on page 10, and you change views, the page numbers get out of sync with the results.

How can I maintain page sync regardless of the selected view?

Posted: Tue May 16, 2006 7:40 am
by velo
Create a variable that stores the record number of the first record being displayed on that page and then when you switch views just begin the display from that record. Then you can calculate pages based on the current record and the total number of records.