In the web project, pagination is the most essential element in which we can displayed large number of data from Mysql database to on webpage. Then in that time Pagination make by Ajax is a very Ajax pagination is a excellent idea because it will assist to increase visibility of your website User Interface. This tutorial will help you about how can you create the Ajax pagination in PHP Object Oriented programming Script using jQuery and MySQL. Here We have made the very simple but very powerful code to developed pagination with jQuery, Ajax, PHP, and MySQL.
By using Object Oriented PHP Script, We have first load data from the MySQL database with the Ajax pagination links. By Click on this Ajax pagination links, you can fetch the database table records except the records which you want to displayed. jQuery and Ajax will assist to fetch the data from the mysql database based on pagination links without refreshing of the page.
First We have make changes in load_data() function, in this function we have add first one argument like page.
After this in that function we have add that page argument data has been passed in Ajax data option to send the value of this page variable to action.php page.
Write JQuery code on click on pagination links. Here .pagination_link is the class name of Ajax Pagination Link. When click on pagination link this code will execute and it will fetch value from id attribute of particular pagination link. In an id attribute we have store page number. After fetching page number we have called load_data(page) function and in that function we have pass value of page variable and that function load data for that page.
This code write on action.php page under load data if condition. Here first $record_per_page = 5; That means we have set display five records on web page. Then after we have define $page variable. In this variable store the value of $_POST["page"] variable which is comes from ajax method. If it not received $_POST["page] variable then we have set $page variable value to 1.
After this we have calculate from where we have start fetching data from database.
After this we have called get_data_in_table() function which we have made under crud class, this function will execute query and display result in table format
Make one function with name like make_pagination_link() in crud class, this function has generate pagination link and send pagination link.
Again go to action.php and called make_pagination_link() which return pagination link html format and which we have send to index page.