Hi all,
I am working on a pagination script which also uses a META TAG refresh in my header section to automat the screen output. The problem I am having is the last six records are not been displayed.
I currently have 110 records in my data source but is is dynamic and could be less or more throughout the day. The script is set to display 14 records per page and produces 7 full pages (14 records) but does not display the last page containing whatever records are left.
$maxRows_fids = 14;
$pageNum_fids = 0;
if (isset($_GET['pageNum_fids'])) {
$pageNum_fids = $_GET['pageNum_fids'];
}
$startRow_fids = $pageNum_fids * $maxRows_fids;
mysql_select_db($database_flightq, $flightq);
$query_fids = "SELECT * FROM flightdata WHERE ArrivalOrDeparture = 'I' AND FIDSFlightDisplay = 'Y' ORDER BY ScheduledDateTime ASC";
$query_limit_fids = sprintf("%s LIMIT %d, %d", $query_fids, $startRow_fids, $maxRows_fids);
$fids = mysql_query($query_limit_fids, $flightq) or die(mysql_error());
$row_fids = mysql_fetch_assoc($fids);
$totalRows_fids = mysql_num_rows($fids);
if (isset($_GET['totalRows_fids'])) {
$totalRows_fids = $_GET['totalRows_fids'];
} else {
$all_fids = mysql_query($query_fids);
$totalRows_fids = mysql_num_rows($all_fids);
}
$totalPages_fids = ceil($totalRows_fids/$maxRows_fids)-1;
$queryString_fids = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_fids") == false &&
stristr($param, "totalRows_fids") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_fids = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_fids = sprintf("&totalRows_fids=%d%s", $totalRows_fids, $queryString_fids);
The META TAG is:
<meta http-equiv="refresh" content="15;url=<?php printf("%s?pageNum_fids=%d%s", $currentPage, min($totalPages_fids, $pageNum_fids +1), $queryString_fids);?>" />
If I were to include manual buttons the script works fine displaying all 8 pages with the last few records on page 8. Can I only think it is something to to with me META TAG but what I have no idea.
Can anyone see why this is happening.