hoangthi Posted October 25, 2013 Share Posted October 25, 2013 (edited) 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 October 25, 2013 by hoangthi Quote Link to comment https://forums.phpfreaks.com/topic/283256-limit-the-results-in-a-page-mysql/ Share on other sites More sharing options...
requinix Posted October 25, 2013 Share Posted October 25, 2013 Modify the query so that it only retrieves one page of results at a time. Use a LIMIT like SELECT ... LIMIT 100, 20which 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 Quote Link to comment https://forums.phpfreaks.com/topic/283256-limit-the-results-in-a-page-mysql/#findComment-1455333 Share on other sites More sharing options...
QuickOldCar Posted October 25, 2013 Share Posted October 25, 2013 It's called pagination, is an older tutorial here at phpfreaks about it. http://www.phpfreaks.com/tutorial/basic-pagination Someone should update that to mysqli versus mysql. Quote Link to comment https://forums.phpfreaks.com/topic/283256-limit-the-results-in-a-page-mysql/#findComment-1455431 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.