If knowledge is power, then sharing knowledge is ultimate powertrip
Latest Updates
You are here: Home >> Frameworks >> CodeIgnitor >> Pagination in codeigniter

Pagination in codeigniter

I’ve often see forum posts asking why the Pagination class isn’t working. I decided to create a tutorial on the Pagination class for those who need to learn about the pagination class.

Let’s now start with the pagination tutorial. This tutorial assumes that you have connected your CodeIgniter application to the database.

First, we need to create a table.

The method Articles_model() is the constructor. In PHP 4, constructors are named after the class they are located in.

The method get_posts(), retrieves the information from the database. Notice that it has parameters for limiting and the offset of returned rows.

The method count_posts(), retrieves the total number of posts available in the table.

Next on our list is creating the controller function.

Copy and paste and do not worry if you don’t understand that chunk of code yet. We will get back to that later on.

About Jawed Shamshedi

Leave a Reply

Your email address will not be published. Required fields are marked *


Scroll To Top