Pages

Sunday, April 29, 2018

Use Codeigniter Pagination In Your Projects

Use Codeigniter Pagination In Your Projects


Use Codeigniter Pagination In Your Projects

CodeIgniter application usually have at least one database. In an average project, the database produces a lot of queries that need to be presented. The problem is that the display of the results could be messy. This is where pagination in CodeIgniter comes to the rescue.
pagination in codeigniter
In this tutorial, I will demonstrate how to use this technique in your CodeIgniter projects. I will start with the Model, then Controller and finally with the View.

The Model

The model for the demo application carries out two important tasks: It provides a count of the records in the Departments table, and retrieve the list of departments from the table.
The path of the model is models/departments.php. Here is the code for the model: