PHP learner. The pagination script below seems to generally work, but the problem is that on each page of 20 records, when I select some rows (via checkboxes) and click the SUBMIT button, the display of 20 records jumps back to page 1. The rows are selected without a problem, but I can't grasp why it returns to page 1.
Is the problem obvious in the script below? Thanks!
//-----------------|
// Add pagination.
//-----------------|
$nAdjacentPages = 3;
// If the current page number is greater than 1, then display:
// "<<" and "<" (i.e., << < ).
if ($nCurrentPage > 1)
{
echo " <a href =
'{$_SERVER['PHP_SELF']}?nCurrentPage=1'> << </a> " ;
$nPreviousPage = $nCurrentPage - 1 ;
echo " <a href =
'{$_SERVER['PHP_SELF']}?nCurrentPage=$nPreviousPage'> < </a> ";
}
// Appearance of page links when viewing page 5:
// << < 2 3 4 [5] 6 7 8 > >>
for ( $x = ( $nCurrentPage - $nAdjacentPages ) ;
$x < ( ( $nCurrentPage + $nAdjacentPages ) + 1 ) ;
$x++ )
{
// if it's a valid page number...
if ( ( $x > 0 ) and ( $x <= $nTotalPages ) )
{
// If on current page, 'highlight' but do not link.
// If not current page, make it a link.
if ( $x == $nCurrentPage )
{
echo " [<b> $x </b>] " ;
}
else
{
echo " <a href=
'{$_SERVER['PHP_SELF']}?nCurrentPage=$x'> $x </a> " ;
}
}
}
// If not last page, show '>' and '>>' links.
if ( $nCurrentPage != $nTotalPages )
{
$nNextPage = $nCurrentPage + 1;
echo " <a href =
'{$_SERVER['PHP_SELF']}?nCurrentPage=$nNextPage'> > </a> ";
echo " <a href =
'{$_SERVER['PHP_SELF']}?nCurrentPage=$nTotalPages'> >> </a> ";
}
?>