Controller:
------------------------
Model:
----------------------
Views:
-----------
------------------------
public function index() {
$count = $this->dcategory->Count_drugcategories();
$page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0;
$this->load->library('pagination');
$config['base_url'] = base_url('drug_categories');
$config['use_page_numbers'] = TRUE;
$config['total_rows'] = $count;
$config['per_page'] = 10;
$config["uri_segment"] = 2;
$this->pagination->initialize($config);
$limit = $config['per_page'];
$start = ($page == 0) ? 0 : ($page * $config['per_page']) - $config['per_page'];
$data['query'] = $this->dcategory->Getlist_drugcategories($start,$limit);
$seo['title'] = 'Drug Categories List | ekimed';
$data['links'] = $this->pagination->create_links();
$this->load->view('layout/header',$seo);
$this->load->view('drug_categories/listdrugcategories',$data);
$this->load->view('layout/footer');
}
Model:
----------------------
function Getlist_drugcategories($limit=0,$start=0){
$this->db->select('*');
if($limit>0 && $start>=0) {
$this->db->limit($limit,$start);
} else {
$this->db->limit(10);
}
$query = $this->db->get($this->drugs_category);
if($query->num_rows() > 0){
return $query->result();
}
return FALSE;
}
Views:
-----------
<?php echo $links; ?>