Difference between revisions of "PHP:Pagination"
Jump to navigation
Jump to search
(Created page with "Category:PHP <syntaxhighlight lang=php> <?php //Paging query results. Finding what paging links to display. Using: // $pageNum (current Page) // $maxPage (maximum pagenu...") |
(No difference)
|
Latest revision as of 10:06, 10 June 2019
<?php
//Paging query results. Finding what paging links to display. Using:
// $pageNum (current Page)
// $maxPage (maximum pagenumber we can have (ceil($numrows/$rowsPerPage);)
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
$first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$self?page=$page\">[Next]</a> ";
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
$last = ' '; // nor the last page link
}
// print the navigation link
// echo "Page : ". $page . " Maxpage : " . $maxPage . " pageNum : ". $pageNum;
echo $first . $prev . $nav . $next . $last;
?>