Hi sneakyimp,
Many thanks for your reply. It made me sit down and do some thinking.
What I came up with works to a degree. If I set the max number of row to be displayed tp 10, run the script I get odd results.
The SQL query result gives me 13 pages to display.
The 1st displays 13 records,
The 2nd page displays 12 records,
The 3rd page displays 11 records,
The 4th pages displays 10 records,
The 5th page displays 8 records,
The 6th page displays 11 records,
In my code below, can you see anything that may be causing this to happen.
[PHP
$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 = 'O' 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);
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;
$currentPage = $_SERVER["PHP_SELF"];
$queryString_fids = "";
if (!empty($SERVER['QUERY_STRING'])) {
$params = explode("&", $SERVER['QUERY_STRING']);
$newParams = array();
$newParams;
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));
}
}
[/code]
<meta http-equiv="refresh" content="15;url=<?php printf("%s?pageNum_fids=%d%s", $currentPage, min($totalPages_fids, $pageNum_fids + 1), $queryString_fids);?>" />