I noticed when I click next and get to the last record of the database, it shows a blank ID in the link and the page ruins. I want to know how to go back to the first record in the database after the person has reached the last record. Same goes when I click the Previous button to the last record, it ruins the page and shows a blank hyperlink.
[php]<?php
$_GET[‘id’]=$id;
$currentid = $id;
$prevquery= “SELECT * FROM database WHERE fldID < $currentid ORDER BY fldID DESC LIMIT 1”;
$prevresult = mysqli_query($conn,$prevquery) or die(mysqli_error());
while($prevrow = mysqli_fetch_array($prevresult))
{
$previd = $prevrow[‘fldID’];
}
$nextquery= “SELECT * FROM database WHERE fldID > $currentid ORDER BY fldID ASC LIMIT 1”;
$nextresult = mysqli_query($conn,$nextquery) or die(mysqli_error());
while($nextrow = mysqli_fetch_array($nextresult))
{
$nextid = $nextrow[‘fldID’];
}
?>
Previous
Next[/php]