how to solve pagination second page link for displaying details? - php

I am doing pagination in CodeIgniter.
Data is loading correctly but when I click on next, it will display a blank page.
Everything is configured properly.
Loaded pagination library also.
But that link is not working.
My model is:
public function record_count_apartment() {
return $this->db->count_all("apartments");
}
function get_apartment_details($limit, $start)
{ $this->db->limit($limit, $start);
$this->db->select('*');
$this->db->from('apartments');
$query = $this->db->get();
return $query->result();
}
My controller is:
$config = array();
$config["base_url"] = base_url() . "search";
$config["per_page"] = 1;
$config["uri_segment"] = 2;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['num_links'] = 2;
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$config['use_page_numbers'] = TRUE;
$config["total_rows"] = $this->get_search_details_model->record_count_apartment();
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$data['apartments'] = $this->get_search_details_model->get_apartment_details($config["per_page"], $page );
$data["links"] = $this->pagination->create_links();
//print_r($data);
$this->layouts->view('user/user_apartments_view', array('left_sidebar' => 'sidebar/left_sidebar','right_sidebar' => 'sidebar/right_sidebar'),$data,TRUE);
My view is:
<div class="container">
<div class="container col-lg-12 " style="background-color:#49BF4C; margin-top:0.5em;">
<div class="col-lg-12">
<strong> <h3 style="color:white; font-weight:900; font-size:1.5em; text-align:center; ">Apartments</h3> </strong>
</div>
</div>
<?php
foreach( $apartments as $apartment) { ?>
<div class="col-lg-3">
<?php echo $apartment->a_name;?> <br>
<?php echo $apartment->a_cityname;?> <br>
<?php echo $apartment->a_desc;?> <br>
</div>
<?php } ?>
<div class="col-lg-12">
<?php echo $links; ?>
</div>
</div>

if you are using the bootstrap framework, use below pagination code customized for bootstrap:-
$config["base_url"] = base_url() . "search";
$config['total_rows'] = $this->get_search_details_model->record_count_apartment();
$config['per_page'] = 10;
$config['num_links'] = 2;
$config['uri_segment'] = 3;
$config['full_tag_open'] = '<ul class="pagination pagination-sm no-margin pull-right">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#"><b>';
$config['cur_tag_close'] = '</b></a></li>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'page';
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
$data['apartments'] = $this->get_search_details_model->get_apartment_details($config["per_page"], $page );
$this->layouts->view('user/user_apartments_view', array('left_sidebar' => 'sidebar/left_sidebar','right_sidebar' => 'sidebar/right_sidebar'),$data,TRUE);

I think problem is in your configuration of pagination library
$config["base_url"] = base_url() . "search";
$config["per_page"] = 1;
$config["uri_segment"] = 2;
Instead of above code you should write
$config["base_url"] = base_url() . "search/index";
$config["per_page"] = 1;
$config["uri_segment"] = 3;

Related

Simple Pagination to blog written in codeigniter

I am trying to create a simple pagination in my CodeIgniter blog, here is my code, I am using auto loader for these
$autoload['libraries'] = array('database','session','pagination');
$autoload['helper'] = array('form','url');
My Controller;
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('BlogModel');
}
public function index($offset=0)
{
$this->load->library('table');
$config["base_url"] = base_url('blog');
//$config["total_rows"] = $this->BlogModel->get_Count(); // There are currently 36 Posts
$config["total_rows"] = 36; // There are currently 36 Posts
$config["per_page"] = 5; // Change limit to suit what you would like
$config['use_page_numbers'] = TRUE;
$limit = $config['per_page'];
$this->pagination->initialize($config);
$blog_pagination = $this->pagination->create_links();
$Posts = $this->BlogModel->get_Posts($limit, $offset);
$assignData=array('data'=>$Posts,'blog_pagination'=>$blog_pagination);
$this->load->view('header');
$this->load->view('blog', $assignData);
$this->load->view('footer');
}
}
I Have this in my Model;
<?php
class BlogModel extends CI_Model {
public function __construct(){
// Call the Model constructor
parent::__construct();
$this->load->library('memcached_library');
}
public function get_Posts($limit, $offset){
$this->db->select('*');
$this->db->where('post_status','published');
$query= $this->db->get('cms_posts',$limit, $offset);
$data=$query->result_array();
return $data;
}
public function get_Count() {
//$query = $this->db->get($this->db->dbprefix . 'blog');
$this->db->select('*')->from('cms_posts');
$this->db->where('post_status','published');
$query= $this->db->get();
//$data=$query->result_array();
return $query->num_rows();
}
}
?>
I am using this in my View;
<div id="primary" class="left-column">
<?php
if(!empty($data)){
foreach($data as $row){
?>
<main id="main" role="main">
<article id="<?php echo $row['post_id']; ?>" class="post-item">
<div class="right">
<div class="post-thumbnail">
<img src="<?php echo base_url()."assets/images/uploads/test_n-150x150.jpg";?>" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" sizes="(max-width: 320px) 100vw, 320px" width="320" height="143">
</div>
<!-- END .post-thumbnail -->
</div>
<div class="left">
<h2 class="post-title">
<?php echo $row['post_title']; ?>
</h2>
<div class="post-meta">
<span class="vcard author">
<?php echo ucwords($row['post_author']); ?>
</span>
<time class="entry-date published" datetime="<?php echo $row['post_date']; ?>"><?php echo date("d M Y", strtotime($row['post_date'])); ?></time>
</div>
<div class="post-excerpt">
<p>
<?php
echo(substr($row['post_content'], 0, 250));
<a class="read-more" href="<?php echo base_url()."blog/".$row['post_url']; ?>">Read More »</a>
</p>
</div>
<!-- END .post-excerpt -->
</div>
<!-- END .left -->
</article>
<!-- END .post-item -->
</main>
<?php
}
}
?>
<!-- END .site-main -->
<div class="pagination-wrap">
<?php echo $blog_pagination; ?>
</div>
</div>
EDIT:
My Route is as under:
$route['default_controller'] = 'index';
$route['blog/:any'] = 'blog/post/$1';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
I don't know that what and where are I am missing something, please lead me or correct me in this code. thnk you
Update
My Blog show now 5 Post on First Page and create Pagination but on only 123>Last› pagination is created and there is page blank on offset 2 (/blog/2).
maybee you can use my methode use uri segment to $offset, like this
public function house()
{
$config['base_url'] = site_url().'/user/house/';
$config['total_rows'] = $this->houses->select_row_house_design();
$config['per_page'] = 12;
$config['cur_tag_open'] = '<li><a><b>';
$config['cur_tag_close'] = '</li></a></b>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$this->pagination->initialize($config);
$from = $this->uri->segment('3');
$data['design'] = $this->houses->select_all_house_design($config['per_page'],$from);
$title['menu'] = 'house design';
$this->template('user/house',$data,$title);
}
set controller like this,
this is also simple
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('BlogModel');
$this->load->library('table');
}
public function index($offset=0)
{
$config['base_url'] = site_url('blog/index');
$config["total_rows"] = $this->BlogModel->get_Count(); // There are currently 36 Posts
$config["per_page"] = 5; // Change limit to suit what you would like
$config['num_links'] = 10;
/*use this code for bootstrap
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a class="">';
$config['cur_tag_close'] = '</a></li>';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '<li>';
$config['next_tag_open'] = '<li class="next">';
$config['next_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['first_link'] = '<<';
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['last_link'] = '>>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
*/
$this->pagination->initialize($config);
$data['blog_pagination'] = $this->pagination->create_links();
$data['posts'] = $this->BlogModel->get_Posts($config['per_page'],$this->uri->segment(3));
$this->load->view('header');
$this->load->view('blog', $data);
$this->load->view('footer');
}
}

pagination is not working in codeignitier

Listing doctors information using pagination. But listing all doctors information from Database in one page.
Controller
public function doctor_userlist_view($offset = 0)
{
$config["base_url"] = base_url() . "User/doctor_userlist_view/";
$config['total_rows'] = $this->db->count_all_results('tbl_doctor');
$config['per_page'] = 4;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = 'Prev';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$data['docList'] = $this->User_model->get_all_userdoctor($config['per_page'], $offset);
$data['get_specs'] = $this->specialisation_model->get_specialisation();
$data['docsideList'] = $this->User_model->get_all_userdocside();
$data['get_specs'] = $this->specialisation_model->specialisation_get();
$this->load->view('customer/header', $data);
$this->load->view('customer/side_view', $data);
$this->load->view('customer/doctor', $data);
$this->load->view('customer/footer');
}
My view
<div class="list">
<ul>
<?php
if(isset($docList)):
foreach ($docList->result() as $row):
?>
<li><div class="imgt"><img src="<?php echo base_url("./resources/images/"); if($row->dr_img) echo $row->dr_img; else echo "no-img.jpg"; ?>" height="90px" width="82px"></div><div class="text"><h3><b>Dr. <?php echo $row->dr_name;?></b><br></h3><p><?php echo $row->spec_specialise; ?><br><?php echo $row->district;?><br><?php echo $row->state;?></p></div><div class="text"></div><div class="link"><i class="ace-icon fa fa-eye sym"></i>View</div></li>
<?php endforeach;
endif;
?>
</ul>
<div class="space">
</div>
</div></div>
<div class="pdt_rightt">
<center>
<?php
echo $this->pagination->create_links();
?>
</center>
</div>
Pagination is not working properly in all links showing the same data. I use same code for listing hospitals in that pagination is working.
You are defining $data['get_specs'] twice, like so...
// This instance of $data['get_specs'] is never being used as it's over written by the one below.
$data['get_specs'] = $this->specialisation_model->get_specialisation();
$data['docsideList'] = $this->User_model->get_all_userdocside();
$data['get_specs'] = $this->specialisation_model->specialisation_get();
So which one is it?
public function get_all_userdoctor($limit, $offset)
{
$this->db->order_by ("id", "desc");
$this->db->select('tbl_doctor.*, tbl_specialisation.*');
$this->db->join('tbl_specialisation', 'tbl_specialisation.spec_id = tbl_doctor.spec_id');
$query = $this->db->get('tbl_doctor', $limit, $offset);
return $query;
}
use this model.Pagination will work properly

Codeigniter pagination showing duplicate records with page query string

i have created pagination with codeigniter 3.
On every page i am getting same results:
my final url seems like: http://localhost/shoping/products/mobile-phones?cid=3&page=2
Controller file:
public function category(){
$category_id = $this->input->get('cid', TRUE);
$slug = $this->uri->segment(2);
$sortby = $this->input->get('sort', TRUE);
$sorttype= 'ASC';
$limit = 10;
$config = array();
$config['base_url'] = base_url() . 'products/'.$slug.'?cid='.$category_id;
$config['total_rows'] = $this->Product_model->category_product_count($category_id);
$config['per_page'] = $limit;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'page';
// $config["uri_segment"] = 3;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_tag_open'] = '<li>';
$config['prev_tag_close'] = '</li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['next_link'] = '»';
$config['cur_tag_open'] = '<li><a class="current">';
$config['cur_tag_close'] = '</a></li>';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$choice = $config["total_rows"] / $config["per_page"];
$config["num_links"] = round($choice);
$this->pagination->initialize($config);
if($this->uri->segment(2) > 0){
$page = ($this->uri->segment(2) + 0)*$config['per_page'] - $config['per_page'];
}
else{
$page = $this->uri->segment(2);
}
$data["links"] = $this->pagination->create_links();
if($data["links"]!= '') {
$data['pagermessage'] = 'Showing '.((($this->pagination->cur_page-1)*$this->pagination->per_page)+1).' to '.($this->pagination->cur_page*$this->pagination->per_page).' of '.$config['total_rows'];
}
if($this->input->get('sort')=='pricelow'){
$sortby = 'price';
$sorttype= 'ASC';
}
elseif($this->input->get('sort')=='pricehigh'){
$sortby = 'price';
$sorttype= 'DESC';
}
elseif($this->input->get('sort')=='new'){
$sortby = 'updated_on';
$sorttype= 'DESC';
}
elseif($this->input->get('sort')=='popularity'){
$sortby = 'price';
$sorttype= 'DESC';
}
else{
$sortby = 'title';
$sorttype= 'ASC';
}
//Get all products
$data['products_by_category'] = $this->Product_model->get_products_by_category($category_id, $config["per_page"], $page, $sortby, $sorttype);
// echo $config['total_rows'];
// Load View
$data['main_content'] = 'public/products_category';
$this->load->view('public/layouts/home_main', $data);
}
Model File:
public function get_products_by_category($category_id, $limit, $start='', $shortby='', $shorttype=''){
$this->db->select('*');
$this->db->where('category_id', $category_id);
$this->db->limit($limit, $start);
$this->db->order_by($shortby, $shorttype);
$query = $this->db->get('products');
if($query->num_rows() > 0){
return $query->result();
}else{
return false;
}
}
and view file:
<?php foreach($products_by_category as $product): ?>
<div class="col-sm-4 col-md-4 col-lg-3">
<div class="single-product" style="height:300px;margin-bottom:10px">
<span class="sale-on">sale</span>
<div class="product-image">
<div class="show-img">
<a href="<?php echo base_url();?><?php echo $product->slug.'?sid='.$product->id;?>">
<img src="<?php echo base_url(); ?>assets/images/products/<?php echo $product->image;?>" alt="<?php echo $product->title;?>" height="150" width="150">
</a>
</div>
</div>
<div class="prod-info">
<h2 class="pro-name">
<?php echo $product->title.$product->id;?>
</h2><br>
<div class="price-box">
<div class="price">
<span><i class="fa fa-inr"></i><?php echo $product->price;?></span>
</div>
<div class="old-price">
<span><i class="fa fa-inr"></i><?php echo $product->mrp_price;?></span>
</div>
</div>
<div class="actions">
<span class="new-pro-wish">
<i class="fa fa-heart-o"></i>
</span>
<span class="new-pro-compaire">
<i class="fa fa-bar-chart"></i>
</span>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
Instead of $this->uri->segment(2), use $this->input->get('page', TRUE).
See CI_Input::get for more information on how you can get query string variables.

Codeigniter Pagination does not work when clicked on further page link

I am working on Codeigniter Pagination and following this link :
http://www.technicalkeeda.com/codeigniter-tutorials/pagination-using-php-codeigniter
but when i click on further links i.e. 1,2 and so on then the next sequence of records does not loads up only the initial (from 1 to 5 shows up) i have seen other links on stackoverflow : CodeIgniter Pagination Page Links Not Working but it did not work. My code is as follows, please help to solve my problem:
Controller: home.php
<?php
class Home extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('MovieModel');
$this->load->library('pagination');
}
public function index($offset=0){
$config['total_rows'] = $this->MovieModel->totalMovies();
$config['base_url'] = base_url().'/home/index';
$config['per_page'] = 5;
$config['uri_segment'] = '2';
$config['full_tag_open'] = '<div class="pagination"><ul>';
$config['full_tag_close'] = '</ul></div>';
$config['first_link'] = '« First';
$config['first_tag_open'] = '<li class="prev page">';
$config['first_tag_close'] = '</li>';
$config['last_link'] = 'Last »';
$config['last_tag_open'] = '<li class="next page">';
$config['last_tag_close'] = '</li>';
$config['next_link'] = 'Next →';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';
$config['prev_link'] = '← Previous';
$config['prev_tag_open'] = '<li class="prev page">';
$config['prev_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li class="page">';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$query = $this->MovieModel->getMovies(5,$this->uri->segment(2));
$data['MOVIES'] = null;
if($query){
$data['MOVIES'] = $query;
}
$this->load->view('index1.php', $data);
}
}
?>
MovieModel.php
<?php
class MovieModel extends CI_Model {
function getMovies($limit=null,$offset=NULL){
$this->db->select("MOVIE_ID,FILM_NAME,DIRECTOR,RELEASE_YEAR");
$this->db->from('trn_movies');
$this->db->limit($limit, $offset);
$query = $this->db->get();
return $query->result();
}
function totalMovies(){
return $this->db->count_all_results('trn_movies');
}
}
?>
View: index1.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Codeigniter Pagination Example</title>
<link href="<?= base_url();?>css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="row">
<h4>Movies List</h4>
<table class="table table-striped table-bordered table-condensed">
<tr><td><strong>Movie Id</strong></td><td><strong>Film Name</strong></td><td><strong>Director</strong></td><td><strong>Release Year</strong></td></tr>
<?php
if(is_array($MOVIES) && count($MOVIES) ) {
foreach($MOVIES as $movie){
?>
<tr><td><?=$movie->MOVIE_ID;?></td><td><?=$movie->FILM_NAME;?></td><td><?=$movie->DIRECTOR;?></td><td><?=$movie->RELEASE_YEAR;?></td></tr>
<?php
}
}?>
</table>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="row"><?php echo $this->pagination->create_links(); ?></div>
</div>
</div>
</div>
</body>
</html>
Use the below coding
if($this->uri->segment(3))
$offset = $this->uri->segment(3);
else
$offset = 0;
$query = $this->MovieModel->getMovies(5,$offset);

Pagination codeigniter not directing to class active link

It so nightmare when using pagination on codeigniter. It work to move another page when click next or number after. But, the 'cur_tag_open' is not move. It still in first link of pagination. So let say, I clicked 3 on [1] [2] [3] , the class active still in one not in three. I can not find the solution of this problem, and this is my code :
CONTROLLER
class Control_direksi extends CI_Controller {
public function index() {
$this->show();
}
public function show() {
/** ======================================================= Inisialisasi table 1 =========================================================* */
$start_row = $this->uri->segment(4);
$per_page = 2;
if (trim($start_row) == '') {
$start_row = 0;
};
$total_rows = $this->model_request->hitungRequestMasukMD();
$this->load->library('pagination');
if ($total_rows != 0) {
$config['base_url'] = base_url() . 'direksi/control_direksi/show/';
$config['total_rows'] = $total_rows;
$config['per_page'] = $per_page;
$config['full_tag_open'] = '<div class="pagination pagination-centered" id="pagination1"><ul>';
$config['full_tag_close'] = '</ul></div><!--pagination-->';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = 'Prev';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'Next';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
}
$data['level'] = $this->session->userdata('level');
$data['pengguna'] = $this->model_user->get_username($this->session->userdata('username'));
$data['data_request_done'] = $this->model_request->get_data_request_belum_terkoreksi($per_page, $start_row);
$data['hitung_Request_Masuk_MD'] = $total_rows;
$this->load->view('direksi/view_direksi', $data);
}
VIEW
<body>
<!-- start: Header -->
<?php $this->load->view('/direksi/include/header.php') ?>
<!-- start: Header -->
<div class="container-fluid-full">
<div class="row-fluid">
<noscript>
<div class="alert alert-block span12">
<h4 class="alert-heading">Warning!</h4>
<p>You need to have JavaScript enabled to use this site.</p>
</div>
</noscript>
<!-- start: Content -->
<marquee>Jumlah Request Masuk ke MD: <?php echo $hitung_Request_Masuk_MD . ' request' ?></marquee>
<div class="box-header">
<h2><i class="halflings-icon align-justify"></i><span class="break"></span>Request masuk ke IT</h2>
<div class="box-icon">
<i class="halflings-icon chevron-up"></i>
</div>
</div>
<div class="box-content" id="things_table">
<?php $this->load->view('direksi/view_direksi_table'); ?>
</div>
</div>
</div>
<!-- end: Content -->
<?php $this->load->view('direksi/view_direksi_table_modal', TRUE); ?>
<div class="clearfix"></div>
<?php $this->load->view('/include/js.html', TRUE); ?>
</body>
Any help, it so appreciated
change 01
$start_row = $this->uri->segment(4);//remove this
and post after
$config['base_url'] = base_url() . 'direksi/control_direksi/show/';
$config['total_rows'] = $total_rows;
$config['per_page'] = 2;
$config['uri_segment'] = 3;//Uri_Segment
Change 02
$data['pagination'] = $this->pagination->create_links();
modify like this
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;//Add this line
$data['links'] = $this->pagination->create_links();
Change 03
in view.
where you want show your pagination list just use
<?php
echo $links;
?>
Important load this library in controller as well
$this->load->library('pagination');

Categories