I have a pagination function that I use for my database search that limits the results per page to 25. However, I have roughly 2300 entries and when someone does a search that queries a lot of results I end up with 90 or so pagination links at the bottom of my page. I would like to limit the pagination navigator to only show 10 pages at a time, adjusting accordingly with page spelunking.
I'm not quite sure how to adjust my script.
Any help would be greatly appreciated.
My current function is so:
$search_function is a javascript function for getting the proper URL, $classical_guitar is referring to images.
function generate_page_links($cur_page, $num_pages) {
global $search_function, $classical_guitarL, $classical_guitarR;
$page_links = '';
// If this page is not the first page, generate the "previous" link
if ($cur_page > 1) {
$page_links .= '<a href="javascript:' . $search_function . "('', '" . ($cur_page - 1) . "');\">" . $classical_guitarL . "</a> ";
}
else {
$page_links .= '';
}
// Loop through the pages generating the page number links
for ($i = 1; $i <= $num_pages; $i++) {
if ($cur_page == $i) {
$page_links .= ' ' . $i;
}
else {
$page_links .= '<a href="javascript:' . $search_function . "('', '" . $i . "');\"> " . $i . "</a> ";
}
}
// If this page is not the last page, generate the "next" link
if ($cur_page < $num_pages) {
$page_links .= '<a href="javascript:' . $search_function . "('', '" . ($cur_page + 1) . "');\">" . $classical_guitarR . "</a> ";
}
else {
$page_links .= '';
}
return $page_links;
}