Welcome Guest, Not a member yet? Register   Sign In
How use class pagination with Join ?
#2

[eluser]Atharva[/eluser]
Code:
function index(){
      $this->load->library('pagination');

      $per_page= 5;
      $offset = (int) $this->uri->segment(3, 0);

      $config['base_url'] = base_url().index_page().'controller/index/';
      $this->db->select('*');
      $this->db->from('blogs');
      $this->db->join('comments', 'comments.id = blogs.id');

      $this->db->limit($per_page,$offset);

      $data['records'] = $this->db->get();

      $data['total_rows'] = $this->db->query("SELECT COUNT(id) AS cnt FROM blogs b INNER JOIN  comments c ON  b.id = c.id")->row()->cnt;



      $config['total_rows'] = $data['total_rows'];
      $config['uri_segment'] = 3;
      $config['num_links'] = 3 ;
      $config['per_page'] = $per_page;
      $this->pagination->initialize($config);
      $data['offset']=$offset;

      
      $data['links']=$this->pagination->create_links();
      $this->load->view('your_view',$data);
}

And in your_view , you can echo $links to generate links.


Messages In This Thread
How use class pagination with Join ? - by El Forum - 01-14-2011, 05:16 AM
How use class pagination with Join ? - by El Forum - 01-14-2011, 05:28 AM
How use class pagination with Join ? - by El Forum - 01-14-2011, 06:58 AM
How use class pagination with Join ? - by El Forum - 01-14-2011, 02:43 PM
How use class pagination with Join ? - by El Forum - 01-14-2011, 03:26 PM
How use class pagination with Join ? - by El Forum - 01-14-2011, 03:35 PM
How use class pagination with Join ? - by El Forum - 01-14-2011, 04:44 PM
How use class pagination with Join ? - by El Forum - 01-14-2011, 05:24 PM
How use class pagination with Join ? - by El Forum - 01-14-2011, 06:08 PM
How use class pagination with Join ? - by El Forum - 01-14-2011, 06:29 PM
How use class pagination with Join ? - by El Forum - 01-14-2011, 06:48 PM
How use class pagination with Join ? - by El Forum - 01-15-2011, 06:45 AM
How use class pagination with Join ? - by El Forum - 01-15-2011, 08:38 AM
How use class pagination with Join ? - by El Forum - 01-15-2011, 12:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB