I have an SQL query that returns an amount of tuples (about 50). Now I need to display the results, 15 tuples at a time, then I will have a "view more" button to view the next 15 results.
Can you please help me how I can make this? Th开发者_如何学Pythone issue is that I cannot use the 'limits' because each time I run the query the results will be different, hence when pressing view more, I may get the same results of the same page.
thanks
If you can't use LIMIT, this means your script will have to fetch and load the 50 tuples. If you only want to display 15, you should look for a Javascript solution to hide the others and only show the active ones.
The JQuery Datatables is an EXCELLENT piece of work. You just load all the tuples in a table, and call the Datatable - that's it! You can later customize it to show more or less than 15 at a time.
Instead of reloading, you should put each "page" into a display:hidden
div
and using JS you show one div
after another.
If you can only run the query once, you only have two options:
Send the entire resultset to the browser, hiding all but 15 rows. "View more" would simply unhide more rows.
Run the query once and cache the results, but only send back the rows requested to the browser. When more rows are requested from the browser, send back another set of cached rows. This is useful for progressively loading large or complex data sets.
精彩评论