Welcome Guest, Not a member yet? Register   Sign In
Pagintaion
#2

[eluser]OES[/eluser]
Hi Rubiz.

Here is a sample of my code which will hopeully shed some light.

First the controller where I am going to paginate some results.
Code:
function index()
{                    
    $offset = $this->uri->segment(3);
    $perpage = 20;
    $this->data['results'] = $this->Files_model->search_files('', $perpage,$offset);
        
    // Pagination
    $url =  $this->config->site_url();
    $pagination_config['base_url'] = $url.'admin/files/';
    $pagination_config['total_rows'] = count($this->Files_model->list_files());
    $pagination_config['per_page'] = $perpage;        
    $this->pagination->initialize($pagination_config);        
    $this->data['pagination'] = $this->pagination->create_links();
    $this->mysmarty->view('admin/files/welcome', $this->data);
}

And here is a basic model (Files_model) with the function search_files.
Code:
function search_files( $data='', $perpage, $offset='' )
{
    $this->db->select('files');
    $this->db->limit($perpage, $offset);
        
    $this->db->order_by('date', 'DESC');
    $query = $this->db->get('files');
    return $query->result_array();        
}

This should hopefully get you on the right track.

Bare in mind I am passing everything to the view including the pagnation create links.

Good Luck

Lee


Messages In This Thread
Pagintaion - by El Forum - 10-22-2008, 05:12 AM
Pagintaion - by El Forum - 10-22-2008, 06:08 AM
Pagintaion - by El Forum - 10-22-2008, 06:15 AM
Pagintaion - by El Forum - 10-22-2008, 05:31 PM
Pagintaion - by El Forum - 10-23-2008, 01:47 AM
Pagintaion - by El Forum - 10-23-2008, 08:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB