We are using jquery for pagination. We are pulling millions of records from the database and then th jquery does the pagination on the front end. that is a very slow process. Can someone advice us of a solution in php and jquery where we pull 50 records at a time? Thanks
A:
try this.. not sure if that can be any help.. from Rob Conery..
http://blog.wekeroad.com/2009/11/27/paging-records-sucks--use-jquery-to-scroll-just-in-time
Broken Link
2010-04-05 20:34:46
+1
A:
Do you really need/want to use jquery for the pagination aswell?
On the php side you can work out the row number to start from (using page_number-1 * number_of_rows_per_page) so page 1 will start at row 0, page 2 at 50. That way you only grab 50 rows at a time.
jQuery can then be used to style the table and or send an ajax request to the script to retrieve the specific rows.
$page_number = $_GET['page']; //Could POST this if u want to keep your urls tidy
$num_rows_per_page = 50;
$start_row = ($page_number -1) * $num_rows_per_page;
//This will get just the specified number of rows
$sql = "SELECT * from mytable LIMIT $start_row, $num_rows_per_page"
cast01
2010-04-06 00:31:54
A:
Yes, you should use ajax instead of retrieving the whole thing, try this:
$.get("path/to/page.php", { param1: "myParam1", page: "pagenumber" },
function(data){
$('#datacontainer').html(data);
});
For further information on the $.get
funtion read this: http://api.jquery.com/jQuery.get/
Ben
2010-04-06 04:26:40