How to stay in current data in first page even though im going to second page or back button and if im going back again to the first page when the current data is the same?
in my first page there is a next button and the existing data and that is number 1, the number 1 is containing of my data in database then if i click the next button other data will show or the number 2 data. on this scenario i want to go to 2nd page or ill click the back button if want to see other things afterwards. i want to go back again to the first page where my current data is number 2.
on my code if i click next button then existing is 2 and click the back button and click the first page again. it will back again to 1.
this is my code
<div class="card card-register mx-auto mt-5">
<div class="card-header">Queuing System
<div class="card-body">
<div class="form-group">
<div class="form-row">
<div class="col">
<div class="form-label-group">
<link href="pagination.css" type="text/css" rel="stylesheet">
<?php
include 'myconn.php';
$rowperpage = 1;
$row = 0;
// Next Button
if(isset($_POST['Next'])){
$row = $_POST['row'];
$allcount = $_POST['allcount'];
$val = $row + $rowperpage;
if( $val < $allcount ){
$row = $val;
}
}
?>
</head>
<body>
<div id="content">
<table width="100%" id="emp_table" >
<tr class="tr_header">
<th>Queuing Number</th>
<th>First Name</th>
<th>LastName</th>
</tr>
<?php
// count total number of rows
$sql = "SELECT COUNT(*) AS cntrows FROM accounting_1";
$result = mysqli_query($con,$sql);
$fetchresult = mysqli_fetch_array($result);
$allcount = $fetchresult['cntrows'];
// selecting rows
$sql = "SELECT * FROM accounting_1 ORDER BY que_number ASC limit $row,".$rowperpage;
$result = mysqli_query($con,$sql);
$que_number = $row + 1;
while($fetch = mysqli_fetch_array($result)){
$fname = $fetch['fname'];
$lname = $fetch['lname'];
?>
<tr>
<td align='center'><?php echo $que_number; ?></td>
<td align='center'><?php echo $fname; ?></td>
<td align='center'><?php echo $lname; ?></td>
</tr>
<?php
$que_number ++;
}
?>
</table>
<form method="post" action="">
<div id="div_pagination">
<input type="hidden" name="row" value="<?php echo $row; ?>">
<input type="hidden" name="allcount" value="<?php echo $allcount; ?>">
<!--next button -->
<br>
<div class="row">
<div class="col-sm-6">
<br>
<button type="submit" id="nextBtn" class="btn btn-danger btn-block" name="Next">Next</button>
</div>
<div class="col-sm-6">
<br>
<a class="btn btn-danger btn-block" href="AccountingOfficer.php" data-toggle="modal" data-target="#logoutModal" >Back</a>
</div>
</div>
i expect the output is
if i click next button then existing is 2 and click the back button and click the first page again. it will be exist to 2 not back at 1