HMShingala

.bdr{ border:1px dotted rgba(34,56,235,1.00); background:rgba(192,192,192,1.00); }

Bootstrap Paginaton With Codeigniter

Bootstrap Paginaton With Codeigniter
Controller Code:::

Load Pagination library in your controler:

$this->load->library(“pagination”);

Code::– public function view() {
// $data[‘result’]=$this->nj_user->getallUser();
$this->load->view(‘layout/header’);
$this->load->view(‘layout/sidebar’);
//Pagination
$config = array();
$config[“base_url”] = $this->config->base_url() . “user/view”;
$config[“total_rows”] = $this->nj_user->count_user();
$config[“per_page”] = 7;
$config[“uri_segment”] = 3;
$choice = $config[“total_rows”] / $config[“per_page”];
$config[“num_links”] = round($choice);
//config for bootstrap pagination class integration
$config[‘full_tag_open’] = ‘

    ‘;
    $config[‘full_tag_close’] = ‘

‘;
$config[‘first_link’] = false;
$config[‘last_link’] = false;
$config[‘first_tag_open’] = ‘

  • ‘;
    $config[‘first_tag_close’] = ‘
  • ‘;
    $config[‘prev_link’] = ‘&laquo’;
    $config[‘prev_tag_open’] = ‘

    ‘;
    $config[‘next_link’] = ‘&raquo’;
    $config[‘next_tag_open’] = ‘

  • ‘;
    $config[‘next_tag_close’] = ‘
  • ‘;
    $config[‘last_tag_open’] = ‘

  • ‘;
    $config[‘last_tag_close’] = ‘
  • ‘;
    $config[‘cur_tag_open’] = ‘

  • ‘;
    $config[‘cur_tag_close’] = ‘
  • ‘;
    $config[‘num_tag_open’] = ‘

  • ‘;
    $config[‘num_tag_close’] = ‘
  • ‘;
    $this->pagination->initialize($config);
    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data[‘result’] = $this->nj_user->getallUser($config[“per_page”], $page);
    $data[“link”] = $this->pagination->create_links();
    $this->load->view(‘user/userview’, $data);
    $this->load->view(‘layout/footer’);
    }

    Model code::-
    function getallUser($limit = NULL,$start =NULL)
    {
    $sql=”Select * From nj_user limit $start,$limit”;
    $res=$this->db->query($sql);
    return $res->result();
    }

    function count_user()
    {
    return $this->db->count_all(“nj_user”);
    }

    View code::-
    set following link in your page where you want to show pagination

    Ex:-

    ……..
    ……’

    data of table

    Priview

    One Response

    Leave a Reply

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

    16 + 17 =