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!

Edited by hoangthi
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.