0

I am making pagination in PHP. I need to store records from db to an table and show it on page. I need to mark every record starting from 1 to the end (1,2,3,4....). The script I am using works fine, but I have only one problem regarding marking records. For ex. I want 30 records per page and 30 records are shown correctly 1-30, but when I go to second page numbering starts all over again (It goes again 1-30, instead 31-60), basically numbering is same on every page (1-30). Here is the part of a script where numbering is done.

  $no=0;
            while($row = mysqli_fetch_array($res_data)){            
    $no++;
    echo "<center><table><tr><td style='width: 20%;'>" .$no. "</td><td>" . $row["username"]. "</td><td style='width: 20%;'>" . $row["score"] . "</td></tr>";
    
    echo "</table></center>";
            }

I did not show entire script for pagination, since I think there is no need to because the problem is probably with the $no var. Any help is appreciated!

Ricky97
  • 79
  • 8
  • 2
    Every time you run this script, you start `$no` at 0, you need to initialize the start of the counter based on a passed value,. – Preston Guillot Sep 12 '20 at 21:52
  • Does this answer your question? [PHP & MySQL Pagination](https://stackoverflow.com/questions/2616697/php-mysql-pagination) – Sysix Sep 12 '20 at 22:24

0 Answers0