[eluser]internut[/eluser]
This is probably very ugly but it seems to be working well thus far. Still have a few things to add.
Its doing pagination, sorting (keeping track of sort during page changes via cookie).
Any thoughts?
Code:
// Here we go with pagination
$data[user_count] = $this->db->count_all('users');
if(get_cookie('user_sort')) {
$sort = get_cookie('user_sort');
}
if($this->uri->segment(4)) {
$sort = $this->uri->segment(4);
setcookie("user_sort", $sort);
};
if(!$sort) { $sort = "last_name"; }
if($this->uri->segment(3)) { $start = $this->uri->segment(3) ; }
if(!$start) { $start = 0; }
$this->load->library('pagination');
$config['base_url'] = site_url() . "/users/page/";
$config['total_rows'] = $data[user_count];
$config['per_page'] = '5';
$config['uri_segment'] = 3;
$config['num_links'] = 5;
$data['query'] = $this->db->query("SELECT * FROM users ORDER BY $sort ASC LIMIT $start,$config[per_page]"); // query time
$this->pagination->initialize($config);
$data[pages] = $this->pagination->create_links();
$data[sys_message] = $this->session->flashdata('sys_message'); // set system message to display
$this->load->view('users_view',$data);