Tech Arise

Ajax Pagination Using CodeIgniter and MySQL

Pagination is one of the most frequently used features for web applications. In this post, We have share how to implement Ajax Pagination Using CodeIgniter and MySQL and enhance it further as per our need. Pagination is the process of dividing a document into discrete pages. This is a very simple example, you can just copy paste, and change according to your requirement.
Before started to implement the Ajax Pagination Using CodeIgniter and MySQL, look files structure:
Step 1: Create the database and Table
For this tutorial, you need a MySQL database with the following table:
Step 2: Initialization CodeIgniter pagination library
Initialization CodeIgniter pagination library (file name: pagination.php) “application/config/” folder.
Step 3: Create Model
Create a model file named Employee_model.php inside “application/models” folder.
Load “pagination” class in controller.
Step 4: Create controllers
Create a controllers file named Employee.php inside “application/controllers” folder.
Step 5:Create a view(header)
Create a view file named header.php inside “application/views/templates” folder.
This view contains the header section of the webpage. The Bootstrap library is used to provide a better UI, so, include it in the header section.
Step 6: Create a view(footer)
Create a view file named footer.php inside “application/views/templates” folder.
This view contains the footer section of the webpage.
Step 7: Create views
Create a views file named index.php inside “application/views/employee” folder.
Step 8: Make Ajax Request and Load Data with Pagination
We will also need to use jQuery code in views index.php in "application/views/employee" directory to load pagination and make Ajax request to load more records.
Exit mobile version