Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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