...

View Full Version : Pagination Help



adammc
02-22-2007, 10:00 PM
Hi Guys,

Can anyone possibly help me fix this pagination code?

It is currently displaying the following:


Showing 10 of 32 parts requests.
1 | 2 | 3 | Next Page


If you click on number 1 for example, it gives you this:



Showing 10 of 32 parts requests.
1 | 2 | 3 | Next Page



The problem with the above is its not exactly logical, If you want to go back to the first page you should be pressing number 1 right, but number 1 holds the 2nd set of results (page2)

Also where it says 'Showing 10 of 32 parts requests' is there a way i can get this to display similiar to google where on page 2 its says 'Showing results 11 - 20 of 32 parts requests'

The pagination code is coming from these calls:


$total_records = mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
mysql_free_result($result);

// if there are more than 1 page run the query like this
if (!isset($filter))
$filter = 0;
$start = $filter * $rows_per_page ;


And the pagination code:



echo "<font class=\"gen\">Showing $number of $total_records parts requests.</font><br><br>";


//showing the navigation links . (Previous)
if ($filter > 0) {
$previous = $filter - 1;
$url = $_SERVER['PHP_SELF'] . "?filter=$previous";
echo "<a href=\"$url\" class='gen'>Prev Page</a>&nbsp;|&nbsp;\n";
}


// page numbering links
if ($pages>1) {
for ($i = 1; $i < $pages; $i++) {
$url = $_SERVER['PHP_SELF'] . "?filter=" . $i;
echo " <a href=\"$url\" class='gen'>$i</a> |";
}
}



//showing the navigation links . (Next)
if ($filter < $pages - 1) {
$next = $filter + 1;
$url = $_SERVER['PHP_SELF'] . "?filter=$next";
echo "<a href=\"$url\" class='gen'> Next Page</a>\n";
}

adammc
02-23-2007, 07:12 AM
anyone ?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum