Created
June 4, 2017 08:16
-
-
Save rintoug/90298671e210eb95755325f110bb4aab to your computer and use it in GitHub Desktop.
How to do Pagination in CodeIgniter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Country extends CI_Controller { | |
public function __construct() | |
{ | |
parent:: __construct(); | |
$this->load->model('Country_model', 'country'); | |
$this->load->library("pagination"); | |
} | |
public function listing() | |
{ | |
$config = array(); | |
$config["base_url"] = base_url() . "country/listing"; | |
$config["total_rows"] = $this->country->total_rows(); | |
$config["per_page"] = 20; | |
$config["uri_segment"] = 3; | |
$this->pagination->initialize($config); | |
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; | |
$data["countries"] = $this->country->get_countries($config["per_page"], $page); | |
$data["links"] = $this->pagination->create_links(); | |
$this->load->view("listing", $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment