Saturday, May 12, 2018

Pagination in codeigniter

public function select_data() {
        $this->config->load('pagination');
        $config = $this->config->item('pagination_config');

        $offset = $this->input->post("p") ? $this->input->post("p") : 1;
        $per_page = $this->input->post("pp") ? $this->input->post("pp") : 10;

        $this->uri->assign_segments(3, $offset);

        $config['base_url'] = site_url('account/select_data');
        $config['total_rows'] = $this->account_model->count_row();
        $config['per_page'] = $per_page;
        $config['uri_segment'] = "3";

        $start = ($offset - 1) * $config['per_page'];

        $this->pagination->initialize($config);

        $data["pagination"] = $this->pagination->create_links();
        $data["total"] = $config['total_rows'];
        $data['start'] = $data["total"] ? $start + 1 : 0;
        $data['end'] = (($start + $config['per_page']) < $config['total_rows']) ? $start + $config['per_page'] : $config['total_rows'];
        $data['account'] = $this->account_model->get_all_account($config['per_page'], $start);
//        $data = $this->account_model->get_account();        
        $this->load->view('account_table', $data);
    }

No comments:

Post a Comment

Product Category Demo in laravel

https://drive.google.com/file/d/1kuyeT3LA22IuN3o_kypOyXesEXMLv31e/view?usp=sharing