Hallo Ich habe folgenden Code mit Seriennummer. und Seitenumbruch. Paginierung funktioniert, aber wenn ich zur nächsten Seite gehe, dann beginnt die Seriennummer von 1. Ich habe 10 Zeilen auf jeder Seite begrenzt, also möchte ich die nächste Seite von SN beginnen. 11-20, 21-30 von der 3. Seite. Bitte hilf mir.Paginierung und Seriennummer php Mysql
<?php include_once("../database/config.php");
$start=0;
$limit=10;
$sn=$start;
if(isset($_GET['mainmdsid']))
{
\t $mainmdsid=$_GET['mainmdsid'];
\t $start=($mainmdsid-1)*$limit;
}
else{
\t $mainmdsid=1;
}
\t $result = mysqli_query($mysqli, "SELECT *from item , mainmds , school WHERE empid=$empid AND mainmds.itmid=item.itmid AND mainmds.scid=school.scid LIMIT $start, $limit"); \t
\t
?>
\t \t \t <table align="center" id="customers">
\t <tr>
\t \t <th>SN.</th>
\t \t <th>Item Name</th>
\t \t <th>Quantity</th>
\t \t <th>Status</th>
\t \t <th>If unsatisfactory provide comments </th>
\t \t <th>Date</th>
\t \t <th>School Name</th>
\t \t <th>Variant</th>
\t \t <th>Thana</th>
\t \t
\t \t <th>If others then please specify </th>
\t \t <th>Remove</th> \t \t \t
\t \t
\t </tr>
\t
\t <?php
\t //while($res = mysql_fetch_array($result)) { // mysql_fetch_array is deprecated, we need to use mysqli_fetch_array
\t while($res = mysqli_fetch_array($result)) {
\t $sn+=1;
\t
\t $sdate = $res['sdate'];
\t $fmdate = strtotime($sdate);
\t
\t \t \t
\t \t echo "<tr>";
\t \t echo "<td>".$sn."</td>";
\t \t echo "<td>".$res['itmname']."</td>";
\t \t
\t \t \t if (strpos($empbranch,"NFO")!==false) {
\t \t echo "<td>".$res['DNFO']."</td>"; \t
\t \t }
\t \t else if (strpos($empbranch,"DFO")!==false) {
\t \t echo "<td>".$res['DDFO']."</td>"; \t
\t \t }
\t \t else if (strpos($empbranch,"CO")!==false) {
\t \t echo "<td>".$res['DCO']."</td>"; \t
\t \t }
\t \t else if (strpos($empbranch,"SHARP")!==false) {
\t \t echo "<td>".$res['DSHARP']."</td>"; \t
\t \t }
\t \t else if (strpos($empbranch,"Other")!==false) {
\t \t echo "<td>".$res['DOther']."</td>"; \t
\t \t }
\t \t echo "<td>".$res['istatus']."</td>";
\t \t echo "<td>".$res['usstatus']."</td>";
\t \t
\t \t echo "<td>".$res['sdate']."</td>";
\t \t echo "<td>" .date('d M Y', $fmdate). "</td>";
\t \t echo "<td>".$res['ivariant']."</td>"; \t
\t \t echo "<td>".$res['scthana']."</td>";
\t \t echo "<td>".$res['oscname']."</td>";
\t \t
\t \t \t
\t \t
\t \t \t
\t \t
\t \t echo "<td><a href=\"delete.php?mainmdsid=$res[mainmdsid]\" onClick=\"return confirm('Are you sure you want to delete?')\">Delete</a></td></tr>"; \t \t
\t }
\t ?>
\t </table>
\t
\t <?php
//fetch all the data from database.
$rows=mysqli_num_rows(mysqli_query($dbconfig,"SELECT *from item , mainmds , school WHERE empid=$empid AND mainmds.itmid=item.itmid AND mainmds.scid=school.scid"));
//calculate total page number for the given table in the database
$total=ceil($rows/$limit);?>
<table align="center" border="1">
<?php if($mainmdsid>1)
{
\t //Go to previous page to show previous 10 items. If its in page 1 then it is inactive
\t echo "<tr><td><a href='?mainmdsid=".($mainmdsid-1)."' class='button'>PREVIOUS</a></td>";
}
if($mainmdsid!=$total)
{
\t ////Go to previous page to show next 10 items.
\t echo "<td><a href='?mainmdsid=".($mainmdsid+1)."' class='button'>NEXT</a></td>";
}
?>
<?php
//show all the page link with page number. When click on these numbers go to particular page.
\t \t for($i=1;$i<=$total;$i++)
\t \t {
\t \t \t if($i==$mainmdsid) { echo "<td>".$i."</td>"; }
\t \t \t
\t \t \t else { echo "<td><a href='?mainmdsid=".$i."'>".$i."</a></td>"; }
\t \t }
?>
</tr>
</table>
Beachten Sie, dass Grenze ohne Reihenfolge von ist ziemlich bedeutungslos – Strawberry