Wednesday, April 8, 2015

Pagination Issue in Codeigniter [solved]

There is many students face problem in Pagination library in CI
CodeIgniter

Please update the following code and your problem resolved


public function index($index=1)
    {
        $per_page=2;   // set accorrding to requiremnet
       if($index==1){
           $index=0;
       }
         
         $this->load->model("MODLE_NAME");
            $user_data['user_data']=$this->Model_name->select($per_page,$index);
            $t=$this->Model_name;
            $table_name=$t::table_name;
            $query = $this->db->get($table_name);
            $row_count=$query->num_rows();
   // pagination     
       $this->load->library('pagination');

            $config['base_url'] = base_url().'admin/controller_function/index/';
            $num_rows_pagination=$row_count;
            $config['total_rows'] = $num_rows_pagination;
            $config['per_page'] = $per_page;
             $config['uri_segment'] = 4;
               // pagination formating
                    $config['full_tag_open'] = "<br><ul class='pagination'>";
                    $config['full_tag_close'] ="</ul>";
                    $config['num_tag_open'] = '<li>';
                    $config['num_tag_close'] = '</li>';
                    $config['cur_tag_open'] = "<li class='disabled'><li class='active'><a href='#'>";
                    $config['cur_tag_close'] = "<span class='sr-only'></span></a></li>";
                    $config['next_tag_open'] = "<li>";
                    $config['next_tagl_close'] = "</li>";
                    $config['prev_tag_open'] = "<li>";
                    $config['prev_tagl_close'] = "</li>";
                    $config['first_tag_open'] = "<li>";
                    $config['first_tagl_close'] = "</li>";
                    $config['last_tag_open'] = "<li>";
                    $config['last_tagl_close'] = "</li>";
            
            $this->pagination->initialize($config); 
            $user_data['pagination']= $this->pagination->create_links();
            $user_data['total_row']=$row_count;
            $user_data['page'] = 'controller_function';
        $this->load->view('admin/Manage/view_page',$user_data);   // Customize according its to view panel
       
   }
 
                           //---------------WARNING------------ 
 
//================= YOUR MODEL and Controller According to your Project ================ 

3 comments:

  1. My friend Suggest me this blog and I can say this is the best blog to get the basic knowledge.Thank you so much for this Selenium Training in Chennai

    ReplyDelete
  2. Well explained. Got to learn new things from your Blog on Coded UI.Coded UI Training in Chennai

    ReplyDelete
  3. SAP MM,SD, real Time Training in Chennai
    We provides Best SAP MM,SD Training in Chennai wih real time project assistance by our leading Materail Management Consultant.
    For Free Live Demo @ Call to 8122241286.
    www.thecreatingexperts.com
    SAP MM
    SAP SD

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...