开发者

Limit MySQL Query with Show More button

In PHP/A开发者_如何学CJAX, is there a straight forward way to display a certain number rows from a query (let's say 5) and then have a "show more" button that shows the next 5 (and so on)?


assuming you dont want to use AJAX (because you said "in PHP"): what you can do is use limit in your sql to get only the first few results. You can then generate the page and when you generate the "more" button, you add a query string to the page it has been sent to with something like ?begin=6 so your php script knows where to start.


assuming you are using AJAX: You can use jQuery's $.ajax() function (or any other library, or "raw" javascript, if you like pain) to get the results back with the same url scheme. then replace the content of the container with whatever results you get back.


SELECT info FROM table LIMIT 0,5  //First 5 results
SELECT info FROM table LIMIT 5,5  //Next 5 results
SELECT info FROM table LIMIT 10,5  //Next 5 results
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜