[eluser]JimmyJ[/eluser]
Hey folks, hopefully someone can help me. I'm really finding it difficult to get pagination working. I've sat here for nearly 16 hours up to now with no joy
My controller looks like:
Code:
function view_clients()
{
$data = array();
$config = array();
$offset = 0;
$limit = 20;
$config = array();
$config['base_url'] = base_url()."admin/view_clients";
$config['total_rows'] = $this->db->get('users')->num_rows();
$config['per_page'] = '2';
$config['num_links'] = 20;
$config['uri_segment'] = end($this->uri->segments);
$config['full_tag_open'] = '<p class="pagination">';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);
$this->load->library('table');
$tbl_template = array ( 'table_open' => '<table class="table">' );
$this->table->set_template($tbl_template);
$this->table->set_heading('ID', 'Name', 'E-Mail', 'Edit', 'Delete');
if($query = $this->admin_model->getUsers($limit, $offset)) {
$data['records'] = $query;
}
$data['content'] = 'admin/clients/view';
$this->load->view('templates/admin', $data);
}
My Model:
Code:
function getUsers($limit, $offset) {
$this->db->select('users.*, user_groups.*')
->from('users')
->join('user_groups', 'user_groups.group_id = users.group', 'left')
->limit($limit, $offset);
return $this->db->get();
//return $query->result();
}
My View:
Code:
<?php echo $this->pagination->create_links(); ?>
<?php echo $this->table->generate(); ?>
It's spitting out my table header ok but with no results and 2 pagination links that don't work. Think I'm having a hard time understanding. When I get my head around it, I should be good to go.
Does anyone have any ideas what's wrong with my code?