Skip to content

Instantly share code, notes, and snippets.

@joeykrim
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeykrim/3ef874119a0fbed7b90b to your computer and use it in GitHub Desktop.
Save joeykrim/3ef874119a0fbed7b90b to your computer and use it in GitHub Desktop.
PHP Pagination - Navigation Improvement
// If over 6 pages away from the first page, add a quick link to the first page
if ($page_number > 6) {
$paginationCtrls .= '<a href="' . $_SERVER['PHP_SELF'] . '/page/1">1</a> &nbsp; ... &nbsp; ';
}
// If over 5 pages away from the last page, add a quick link to the last page
if ($page_number < $last_page - 5) {
$paginationCtrls .= ' ... &nbsp; <a href="' . $_SERVER['PHP_SELF'] . '/page/' . $last_page . '">' . $last_page . '</a> &nbsp; ';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment