I've already got a LIMIT within the script..
Here's my code to date
mysql_select_db($database_conVillas, $conVillas);
$sql = "SELECT DISTINCT * FROM villas, pricing1 WHERE villas.resort = 'pollenca' AND villas.beds LIKE '%%' AND pricing1.price != '0' AND pricing1.availability = '1' AND pricing1.week >= 1073088000 AND pricing1.week <= 1074297600 AND villas.id = pricing1.id ";
$maxRows = 5;
$pageNum = 0;
$result = mysql_query($sql);
$result_limit = sprintf("%s LIMIT %d, %d", $result, $startRow, $maxRows);
$totalRows = mysql_num_rows($result);
while($row = mysql_fetch_assoc($result)){
$rows[$row[ID]] = $row; // Any duplication _should_ overwrite the previous instance
echo "<p>";
}
$totalRows = count($rows);
$totalPages = ceil($totalRows/$maxRows)-1;
?>
Showing
record <?php echo ($startRow + 1) ?> to <?php echo min($startRow + $maxRows, $totalRows) ?>
of <?php echo $totalRows ?>
<?php
if ($totalRows == 0){
echo 'Sorry your search did not return any results. Please return to the search page <a href=search.php>here</a>';
} else {
while($row = mysql_fetch_assoc($result)){
$rows[$row[ID]] = $row; // Any duplication _should_ overwrite the previous instance
}
$i = 0;
foreach($rows as $row){
for($row[$i]; $i <= 5; $i++){
$totalRows = count($rows);
echo "<p>";
echo "ID:" .$row[ID]. "<br>";
echo "Name:" .$row[Name]. "<br>";
echo "Short Description:" .$row[Short_Description]. "<br>";
}
}
}
?>
<div align="right">
<a href="<?php printf("%s?pageNum=%d%s&resort=%s&date=%s&beds=%s", $currentPage, max(0, $pageNum - 1), $queryString, $resort, $date, $sleeps); ?>">
<?php if ($pageNum > 0) { // Show if not first page ?>
PREVIOUS
<?php } // Show if not first page ?>
</a>
</div>
<div align="left">
<a href="<?php printf("%s?pageNum=%d%s&resort=%s&date=%s&beds=%s", $currentPage, min($totalPages, $pageNum + 1), $queryString, $resort, $date, $sleeps); ?>">
<?php if ($pageNum < $totalPages) { // Show if not last page ?>
NEXT
<?php } // Show if not last page ?>
</a>
</div>