jhale1966 Posted November 27, 2006 Share Posted November 27, 2006 We have information that I display in tables in PHP. I need to be able to list 5 items per page (since 5 is the max amount that looks like it would fit on a page without running over into the next page.)What is the easiest way to accomplish this?Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/28649-listing-x-amount-of-items-from-a-mysql-database/ Share on other sites More sharing options...
btherl Posted November 28, 2006 Share Posted November 28, 2006 You can order and limit your results.[code=php:0]SELECT * FROM tableORDER BY id ASCLIMIT 0, 5[/code]I think that's the correct Mysql limit syntax. It means "start at row 0, and take 5 rows". Note that you have to order your results by something unique to every row, otherwise you may get different orders from each request. And that would mean your paging wouldn't work properly. Quote Link to comment https://forums.phpfreaks.com/topic/28649-listing-x-amount-of-items-from-a-mysql-database/#findComment-131269 Share on other sites More sharing options...
jhale1966 Posted November 28, 2006 Author Share Posted November 28, 2006 I guess I asked that wrong. :(I have pages of data that come across but I need page breaks every 5 items so when we print it out, it doesn't run across the bottom/top margins. Quote Link to comment https://forums.phpfreaks.com/topic/28649-listing-x-amount-of-items-from-a-mysql-database/#findComment-131696 Share on other sites More sharing options...
joshi_v Posted November 29, 2006 Share Posted November 29, 2006 Well! I guess pagination is what you need to do! right? Quote Link to comment https://forums.phpfreaks.com/topic/28649-listing-x-amount-of-items-from-a-mysql-database/#findComment-131994 Share on other sites More sharing options...
fenway Posted November 29, 2006 Share Posted November 29, 2006 Pagination isn't hard in HTML. Quote Link to comment https://forums.phpfreaks.com/topic/28649-listing-x-amount-of-items-from-a-mysql-database/#findComment-132095 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.