The code is untested, but it should point you into the right direction.
The GET parameter page
controls which section of the result set to show as you set the LIMIT
of the query using the value of page
.
You select the current record from DB as well as the previous and the next. This way, you know if you can generate a link to the next/previous record in your application.
$page = intval($_GET['page']);
$limitStart = $page - 1;
if($limitStart < 0) {
$limitStart = 0;
}
$query = "SELECT caleadID, region, siteaddr1, siteaddr2, siteaddr3, siteaddr4, sitepcode, ";
$query .= "addgennotes, description, value, award, awardaddr1, awardaddr2, awardaddr3, awardaddr4, awardpcode, ";
$query .= "phone_number, fax_number, fldAwardedWebsite, fldAwardedEmail, contact_name, date FROM tblTradesman_Awarded WHERE 1";
$query .= ' LIMIT ' . $limitStart . ',3';
$result = mysqli_query($connection, $query);
confirm_query($result);
$result_array = array();
while($row = mysqli_fetch_assoc($result)) {
$result_array[] = $row;
}
if(intval($page) === 0) {
$previousRecord = NULL;
$currentRecord = $result_array[0];
$nextRecord = $result_array[1];
} else {
$previousRecord = $result_array[0];
$currentRecord = $result_array[1];
$nextRecord = $result_array[2];
}
if($previousRecord) {
$prevPage = $page - 1;
if($prevPage < 0) {
$pagePage = 0;
}
echo '<a href="index.php?page=' . $prevPage . '">previous</a>';
}
if($nextRecord) {
echo '<a href="index.php?page=' . ($page + 1) . '">next</a>';
}