Hi All,
I have a SELECT query that returns data and is then display over a number of pages. The last page does not always have a full screen of data depending on the amount of rows returned.
Is it possible to count the number of rows on the last page displayed?
The query I use along the the code that produces the pagination:
$MinusInterval = 30;
$PlusInterval = 45;
$time = date("H:i", time());
$totalRows_fids = 0;
$startRow_fids = 0;
$maxRows_fids = 17;
$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 ScheduledTime, Flight, Logo, IATALookup, RemarksWithTime, Terminal FROM LHRFlightStats24_Vanilla WHERE CurrentTime BETWEEN DATE_FORMAT(NOW() - INTERVAL $MinusInterval MINUTE, '%H:%i') AND DATE_FORMAT(NOW() + INTERVAL $PlusInterval MINUTE, '%H:%i') AND ArriveDepart = 'O' AND FlightDisplay = 'Y' ORDER BY ScheduledTime 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);
$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);
$pageStr = sprintf("PAGE No:%d%s", $currentPage, min($totalPages_fids, $pageNum_fids + 1), $queryString_fids);
$pageNo = substr($pageStr,9, 3);
//then in the HTML head I have
<meta http-equiv="refresh" content="20;url=<?php printf("%s?pageNum_fids=%d%s", $currentPage, min($totalPages_fids, $pageNum_fids + 1), $queryString_fids);?>" />