Pagination Php codes?

hi i need some help on the pagination codes. i've created a really basic one whereby the user can only click "Previous" or " Next " but i'm trying to do something whereby there are page numbers being displayed and the user can click on whichever page they want to view instead of pressing "next " over and over. If you don't understand what i'm saying, check out this website : http://store.fueledbyramen.com/artists/show_by_artist/7

I'm hoping to do what they did on the website where they show maybe the first three pages and the last three pages.. with dots in the middle to represent the middle pages. Below are my codes, I'd appreciate if you can guide me through on how to improve my current codes. Thanks!

// *** Setup pagination.
$sql = "SELECT * FROM public_subscribe";
$result = mysql_query($sql);

if (!$result) {
echo("<p>Could not get pagination information.");
} else {
$numRecords = mysql_num_rows($result);
$numPages = ceil($numRecords / $numRecsPerPage);

if ($numPages > 1) {
// *** Display pagination controls.
$prevControl = '' ;
$nextControl = '' ;

if($pageNum > 1) {
$prevPage = $pageNum - 1;
$prevControl =
"<a href=\"{$_SERVER['PHP_SELF']}?pageNum=$prevPage\">PREV</a>";}

if ($pageNum < $numPages) {
$nextPage = $pageNum + 1;
$nextControl =
"<a href=\"{$_SERVER['PHP_SELF']}?pageNum=$nextPage\">NEXT</a>";
}
Continue *

// *** Show the pagination controls.
echo "<p><a href='{$_SERVER['PHP_SELF']}?pageNum=1'>FIRST</a> ";
echo("$prevControl Page $pageNum / $numPages $nextControl");
echo " <a href='{$_SERVER['PHP_SELF']}?pageNum=$numPages'>LAST</a> ";

}
}


EDIT*

$p... = $prevPage\">PREV</a>";
$n... = $nextPage\">NEXT</a>";
1'>... = ?pageNum=1'>FIRST</a> "
$nu... = $numPages'>LAST</a> ";

Thanks again! sorry my question look so messy.
 
Back
Top