Wednesday, March 28, 2018

CodeIgniter Pagination With Bootstrap

CodeIgniter Pagination With Bootstrap


CodeIgniter Pagination With Bootstrap

Most of the time in the web application development, we have to show a large amount of data to the users. To show a large amount of data at once decrease the performance of our web application and we definitely want to avoid such problems in our web application.So at this time pagination plays a vital role to improve the performance of our web application. In this tutorial, we are going to learn how to use CodeIgniter pagination class in our web application. Here we are going to use PHP CodeIgniter framework for our backend and Twitter Bootstrap framework for our front end, So it is necessary to have the basic idea of these two frameworks.

Get Started

Codeigniter is a very famous PHP framework due to his large and easy to use libraries. Codeigniter pagination is one such library which is very helpful if we have to show a large amount of data to the users. Codeigniter pagination library breaks the data into the set of numbered links which allows us to navigate from one page to another.

Setting Database for CodeIgniter pagination

Here we use a simple database for the example purpose so that we can see how CodeIgniter pagination library works. Copy the below SQL query and run this to make a simple database of users.
  1. CREATE TABLE `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(256) NOT NULL, `user_email` varchar(256) NOT NULL, `create_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,PRIMARY KEY (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Now We have our table, let�s insert some dummy data into this table. Run the below query to insert data into this table.
  1. INSERT INTO `users` (`user_id`, `user_name`, `user_email`, `create_date`) VALUES(1, John, john@gmail.com, 2017-07-20 16:22:27),(2, Doe, doe@gmail.com, 2017-07-20 16:22:27),(3, Sam, sam@gmail.com, 2017-07-20 16:25:35),(4, Sara, sara@gmail.com, 2017-07-20 16:25:35),(5, Sam, sam@gmail.com, 2017-07-20 16:25:35),(6, Sara, sara@gmail.com, 2017-07-20 16:25:35),(7, Adam, adam@gmail.com, 2017-07-20 16:25:35),(8, Smith, smith@gmail.com, 2017-07-20 16:25:35),(9, Ram, ram@gmail.com, 2017-07-20 16:25:35),(10, Mohan, mohan@gmail.com, 2017-07-20 16:25:35),(11, John, john@gmail.com, 2017-07-20 16:25:35),(12, Ahmad, ahmad@gmail.com, link download