Button to click
<form action='' method='POST'>
<input type='submit' name='submit' />
</form>
Variable to be incremented on button click
$currentid="1";
if(isset($_POST['submit'])){
$sql = "SELECT * from TABLENAME WHERE id='$currentid' LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. "<br>";
//$currentid=$row["id"];
$currentid=$currentid+1;
echo "$currentid";
}
} else {
echo "0 results";
}
}
Task:
I want to increment $currentid="1"
by 1 each time the button is clicked.
This will work same like php pagination but just with Next Button. and on each button click next record will be displayed.
I would appreciate if you can suggest any other better way to achieve the same goal.