Jump to content

Limit the results in a page (Mysql)


hoangthi

Recommended Posts

I am using Php to show a table from mySql database.

The table has too many rows, it 's about 100 +

I only want to show 20 rows each page, and there are 5 pages. I think I can use break function to to that but I don't know how to split to 5 pages.

 

Example

1 something

2 something

3 something

4 something

..

.

20 something

<page1><page2><page3>

_____________________________

21 something

22 something

23 something

24 something

..

.

40 something

<page1><page2><page3>

 

 

Hope you understand my problem and help me!

Link to comment
https://forums.phpfreaks.com/topic/283256-limit-the-results-in-a-page-mysql/
Share on other sites

Modify the query so that it only retrieves one page of results at a time. Use a LIMIT like

SELECT ... LIMIT 100, 20
which will get 20 results starting at the 101st. If you were showing 20 per page and wanted to get page 4 you would do

offset = 20 * (page - 1) = 60
LIMIT 60, 20

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.