aahaider Posted October 17, 2012 Share Posted October 17, 2012 Hi dear friends, I hope u are all fine. I want to make a next button for getting more data from mysql database. For example: $sql = mysql_query("SELECT * FROM table LIMIT 0,7"); It get 7 rows.For next data code is that. $sql = mysql_query("SELECT * FROM table LIMIT 7,7"); I can i do that using ajax. As you can see in many website like facebook,When you click on comment it give a limited comment and when you click on more comment it give more and so on.In this proccess you can see that the other content of page does not change.It means it can use ajax and how can I do that in ajax. Please help me.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/269583-how-to-make-a-next-button-for-more-more-data/ Share on other sites More sharing options...
Jessica Posted October 17, 2012 Share Posted October 17, 2012 Check out jQuery. Quote Link to comment https://forums.phpfreaks.com/topic/269583-how-to-make-a-next-button-for-more-more-data/#findComment-1385769 Share on other sites More sharing options...
codefossa Posted October 22, 2012 Share Posted October 22, 2012 You request the PHP page doing the query with the page number. You use this to multiply by the amount of items to show per page to get the current position. (page 1 - 1) * 20 items = 0 start and 20 limit (page 2 - 1) * 20 items = 20 start and 20 limit If you set the limit as a variable, then you can change this by changing that one number any time in the future. As far as Ajax goes. You can use the regular Ajax function or Jquery's post function, which are both found on this page. http://api.jquery.com/jQuery.post/ You most likely want to use post so you can send the page number you're requesting, but you could also use $_GET if you really want. Just add it onto the page you're requesting. You could just use Jquery's .load function then. Just serialize your data, send it to the page, and fill the div with the resulting data returned from the page you posted to. Quote Link to comment https://forums.phpfreaks.com/topic/269583-how-to-make-a-next-button-for-more-more-data/#findComment-1386957 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.