SelectOne($paginationSql); $totalRecords = $db->_row['rowCount']; $totalPages = ceil($totalRecords / $config->_recordsPerPage); # if the total records are less than what we show per page, then # just skip everything else below if ( $totalRecords <= $config->_recordsPerPage ) { $fromRecord = ($pageOffset + 1); $pageNav .= <<
Displaying: $fromRecord to $totalRecords of $totalRecords results. HTML; return $pageNav; } # either append the proper page with & or ? depending # on whether the submitted URI already has a query # string or not if ( preg_match("/\?.+/", $uri) ) { $uri = "$uri&"; } else { $uri = "$uri?"; } # create the navigation menu if ( $page > 1 ) { $pagePrev = ($page - 1); # if the previous page isn't also the first page, show a link for first page. if ( $pagePrev != 1 ) { $pageNav .= " [First] \n"; } $pageNav .= " Prev\n"; } for ( $idx = 1; $idx <= $totalPages; $idx++ ) { if ( $idx == $page ) { $pageNav .= " $idx \n"; } else { $pageNav .= " $idx \n"; } } if ( ($totalRecords - ($config->_recordsPerPage * $page)) > 0 ) { $pageNext = ($page + 1); $pageNav .= " Next\n"; # if the previous page isn't also the first page, show a link for first page. if ( $pageNext != $totalPages ) { $pageNav .= " [Last] \n"; } } $fromRecord = ($pageOffset + 1); if ( $page == $totalPages ) { $toRecord = $totalRecords; } else { $toRecord = ($pageOffset + $config->_recordsPerPage); } $pageNav .= <<