shortysbest Posted December 4, 2010 Share Posted December 4, 2010 I have a commenting system and i have a limit of a certain number of comments to be shown. What i want to do is have a button on the bottom of the page at the end of the comments that are showing and when you click it ajax loads the next certain number of of rows (but not all of them),and then you click it again and it shows more of them, etc. So for example. comment 1 comment 2 comment 3 comment 4 --click button--(loads 4 more)--- comment 5 comment 6 comment 7 comment 8 --click button--(loads 4 more)-- comment 9 comment 10 comment 11 comment 12 etc. until there are no more rows. what's the best way to do this? (I know how to do the ajax and all, i just need help with the script to select the rows) Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/220683-mysql-limit-show-additional-rows-from-database/ Share on other sites More sharing options...
requinix Posted December 4, 2010 Share Posted December 4, 2010 It's basically just regular pagination: you tell the script which page you want, it figures out which range that corresponds to. Like ajax.php?page=2 would get the HTML for comments 5-8. Your JavaScript then removes the old More link, inserts the new HTML, and inserts a new More link. If you want to know whether the last four retrieved were the actual last four then your ajax.php can return an object instead of just the HTML string: { "hasmore": false, "html": "html for the comments" } Quote Link to comment https://forums.phpfreaks.com/topic/220683-mysql-limit-show-additional-rows-from-database/#findComment-1143028 Share on other sites More sharing options...
ignace Posted December 5, 2010 Share Posted December 5, 2010 Use SQL_CALC_FOUND_ROWS to find out how many exactly are in the result. Quote Link to comment https://forums.phpfreaks.com/topic/220683-mysql-limit-show-additional-rows-from-database/#findComment-1143180 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.