<?php
// Start Pagination
// number of rows to show per page
$rowsperpage = 10;
$numrows1 = $results[total];
// find out total pages
$totalpages = ceil($numrows1 / $rowsperpage);
// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
// cast var as int
$currentpage = (int) $_GET['currentpage'];
} else {
// default page num
$currentpage = 1;
} // end if
// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
} // end if
// the offset of the list, based on current page
$offset = (($currentpage - 1) * $rowsperpage);
$sphinx->SetLimits($offset, $rowsperpage);
echo "<b>Found $results[total_found] Matches</b><br>\n";
$showingto = ($offset + $rowsperpage > $numrows1) ? $numrows1 : $offset + $rowsperpage;
echo "Showing results " . ($offset+1) . " - " . $showingto . " of " . $numrows1;
?>
Comments