i work in small project of reading some data files in excel so i put the data in MySQL data base then read it in php files so it was easy to read and write on it , i make it in pagination pages to easy transfer between rows i trey to make some code in php files as my little experience on it , it work fine and read data from data base and also update it but problem was when i press update button it return me again to first page for example when i was in page 4 and press update he send the data to data base but he return me again to first page
<?php
include('db.php');
if (isset($_GET['page_no']) && $_GET['page_no']!="") {
$page_no = $_GET['page_no'];
} else {
$page_no = 1;
}
$total_records_per_page = 3;
$offset = ($page_no-1) * $total_records_per_page;
$previous_page = $page_no - 1;
$next_page = $page_no + 1;
$adjacents = "2";
$result_count = mysqli_query($con,"SELECT COUNT(*) As total_records FROM `b_2011`");
$total_records = mysqli_fetch_array($result_count);
$total_records = $total_records['total_records'];
$total_no_of_pages = ceil($total_records / $total_records_per_page);
$second_last = $total_no_of_pages - 1; // total page minus 1
$result = mysqli_query($con,"SELECT * FROM `b_2011` LIMIT $offset, $total_records_per_page");
while($row = mysqli_fetch_array($result)){
echo"<form method=post action=index.php>";
echo "<tr>
<td>"."<input type=text name=id value=".$row['id']." </td>
<td>".$row['details_all']."</td>
<td>"."<input type=text name=Class_send value=".$row['classfication']." </td>
<td>" ."<input type=text name=det_send value=".$row['details']." </td>
<td>" ."<input type=submit name=update value= update .</td>
</tr>";
echo "</form>";
}
if (isset($_POST['update']))
{
$ID=$_POST['id'];
$classsication=$_POST['Class_send'];
$details=$_POST['det_send'];
if (mysqli_query($con,"UPDATE b_2011 SET classfication='".$classsication."',details='".$details."' WHERE id=".$ID))
{
echo "records updates";
}
}
?>