Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery pagination

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

like image 466
Asim Zaidi Avatar asked Apr 05 '10 20:04

Asim Zaidi


People also ask

What is jQuery pagination?

Pagination is a very useful characteristic of any application. This article helps uses jQuery and bootstrap to produce a lovely HTML table listing page numbers. Bootstrap is a strong CSS frame for creating the stunning layout and HTML elements with the CSS class.

Does JavaScript do pagination?

JavaScript Pagination concept is applied for moving among the pages with First, Next, Previous and Last buttons or links. Pagination's main motto is to move among the content immediately by clicking links or buttons. Pagination has multiple links or buttons provided for access First, Next, Previous and Last content.


1 Answers

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"
like image 154
cast01 Avatar answered Oct 05 '22 11:10

cast01