I'm trying to make navigation easier for users. I would like to limit the page numbers shown to +/- 5 pages from current page, whereas currently it lists them all.
I've been trying to mess with the following section of my code, but to no luck, but it seems the answer is in this area of code:
I can post more code if needed. I'm not a programmer so easy stuff like this is quite difficult for me. I'm not asking for answers either, I just would like to be pointed in the right direction. Thanks for all input.
I've been trying to mess with the following section of my code, but to no luck, but it seems the answer is in this area of code:
Code:
$self = $_SERVER['PHP_SELF'];
$nav = '';
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= " $page ";
}
else
{
$nav .= " <a href=\"$self?page=$page&id=$id\">$page</a> ";
}
}
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page&id=$id\">[Prev]</a> ";
$first = " <a href=\"$self?page=1&id=$id\">[First Page]</a> ";
}
else
{
$prev = ' ';
$first = ' ';
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page&id=$id\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage&id=$id\">[Last Page]</a> ";
}
else
{
$next = ' ';
$last = ' ';
}
echo $first . $prev . $nav . $next . $last;
I can post more code if needed. I'm not a programmer so easy stuff like this is quite difficult for me. I'm not asking for answers either, I just would like to be pointed in the right direction. Thanks for all input.