I have few tables in my database and want to implement pagination for several tables on the pages. I wrote my own code for pagination in each page wherever it is required. Is there any frame work which can be easily implemented like, when I pass a query to a method or class it has to generate ui with proper pagination.Would any body suggest me any frame work which does this task.
edit: I already specified that I wrote my own code for pagination, it is something very close to the one solution given by @veerendra but for pagination in 60 different pages I need to write that logic. I asked for a framework which reduces my burden of writing the code for pagination which is dynamic and it should be in php not jquery or javascript. As thier logic will reside at client side can't operate on large sets of data.
Try out this below link to display the data with pagination:
http://code.tutsplus.com/tutorials/how-to-paginate-data-with-php--net-2928
check datatables its a great js table framework it allows you to implement ajax calls.
You can use the jquery pagination its simple and fast. Please follow the below steps i have described in depth
Get the zip containing the plugin and the CSS themes here.
Step 1: together with JQuery, include jquery.simplePagination.js in your page:
JQuery 1.7.2 or later is recommended. Older versions might work as well, but i have not tested.
Step 2: OPTIONAL - include the CSS file with the 3 default themes
If you skip this step, you will need to define your own styles or use Bootstrap.
Step 3: call the function on your pagination placeholder:
If necessary, you can specify the number of pages directly, via "pages" parameter, instead of "items" and "itemsOnPage" which are used by the plugin to automatically calculate the number of pages.
Available options
items Integer Default: 1 Total number of items that will be used to calculate the pages.
itemsOnPage Integer Default: 1 Number of items displayed on each page.
pages Integer Optional If specified, items and itemsOnPage will not be used to calculate the number of pages.
displayedPages Integer Default: 5 How many page numbers should be visible while navigating.
Minimum allowed: 3 (previous, current & next) edges Integer Default: 2 How many page numbers are visible at the beginning/ending of the pagination.
currentPage Integer Default: 1 Which page will be selected immediately after init.
hrefTextPrefix String Default: "#page-" A string used to build the href attribute, added before the page number.
hrefTextSuffix String Default: empty string Another string used to build the href attribute, added after the page number.
prevText String Default: "Prev" Text to be display on the previous button.
nextText String Default: "Next" Text to be display on the next button.
labelMap Array Default: empty array A collection of labels that will be used to render the pagination items, replacing the numbers. cssStyle String Default: "light-theme" The class of the CSS theme.
selectOnClick Boolean Default: true Set to false if you don't want to select the page immediately after click.
onPageClick(pageNumber, event) Function Optional Function to call when a page is clicked.
Page number and event are optional parameters. onInit Function Optional Function to call when the pagination is initialized.
Available methods
selectPage - Select a page based on page number.
prevPage - Selects the previous page.
nextPage - Select the next page.
getPagesCount - Returns the total number of pages.
getCurrentPage - Returns the current page number.
disable - Disables pagination functionality.
enable - Enables the pagination after it was previously disabled.
destroy - Visually destroys the pagination, any existing settings are kept.
redraw - The pagination is drawn again using the existing settings. (useful after you have destroyed a pagination for example)
updateItems - allows to dynamically change how many items are rendered by the pagination
updateItemsOnPage - allows to dynamically change how many items are rendered on each page
drawPage - takes a page number as a parameter and it sets the "currentPage" value to the given page number and draws the pagination
Below is the file named paging.inc.php
You just need to pass the where class to the query and just need to get the count only and name the count varibale same as in the file then you will need to set the records per page and other parameters.
After this you need to fire the query which will bring the records with the limit variable from the file and this can be used for sorting the columns in the listing.
Posting a sample code below so you can get what i said in the above description.
This is just a sample how i use it.
Below is the gen_pagingmsg.inc.php
This file basically provide you the message and paging html which you can keep just above or below your listing