1

I want to do pagination based on primary id and display 20 records per page

My database having primary id (auto increment) as follows

    + users +
       id
    -------
      1
      .
      .
   --------
      145
       .
       .
    upto 5000

I'm trying something like this

I'm getting id dynamically into this variable dynamicIdPassed

SELECT * FROM users WHERE id=dynamicIdPassed LIMIT dynamicIdPassed, 20

Thank's in Advance.

Goutham Ggs
  • 91
  • 14
  • Possible duplicate of [Simple PHP Pagination script](https://stackoverflow.com/questions/3705318/simple-php-pagination-script) – trincot Oct 21 '17 at 08:11

1 Answers1

1

You have to set the value for stating index dynamically. Suppose in below query I have set 0 starting index for first page. Like for second page it would be 20*2 then for third page 20*3 and so on.

SELECT * FROM users limit 20 OFFSET 0;
Lokesh Kumar Gaurav
  • 726
  • 1
  • 8
  • 24