Finally my pagination worked.Still there are some problems.In every page its showing only one data and edit delete functionality not working.I tried changing almost everything.Any guidance will be great. *This is my controller*
function view($page=0){
$config = array();
$config["base_url"] = base_url() . "index.php/view_expenses/view";
$config["total_rows"] = $this->emp_expenses_model->getTotalStudentCount();
$config["per_page"] = 5;
$this->pagination->initialize($config);
$this->data["results"] = $this->emp_expenses_model->getStudent($config["per_page"], $page);
$this->data["links"] = $this->pagination->create_links();
$this->data['title'] = 'Payroll System';
$this->data['message'] = $this->session->flashdata('message');
$this->load->view('view_expenses', $this->data);
}
This is the code in my model
function getTotalStudentCount() {
return $this->db->count_all("emp_expenses");
}
function getStudent($limit, $start) {
$this->db->limit($limit, $start);
$qry= $this->db->get("emp_expenses");
return $qry->result();
}
and this is the view
<table cellspacing="0" cellpadding="2" border="0" id="tbl" style="width:100%">
<tr style="background-color:#045c97">
<td class="heading">Expenses ID</td>
<td class="heading">Employee ID</td>
<td class="heading">Drop Down</td>
<td class="heading">Mode OF Payment</td>
<td class="heading">Amount</td>
<td class="heading">Edit</td>
<td class="heading">Delete</td>
</tr>
<?php
foreach($results as $m)
//var_dump($results);die('asd');
?>
<tr style="text-align:center;">
<tr>
<td><?php echo $m->expenses_id ?></td>
<td><?php echo $m->id ?></td>
<td><?php echo $m->dropdown ?></td>
<td><?php echo $m->modeofpayment ?></td>
<td><?php echo $m->amount ?></td>
<td><a href="<?php echo site_url('view_expenses/edit_expenses/'.$m) ?>"class="btn btn-primary btn-mini">Edit</a></td>
<td>
<?php
echo anchor('view_expenses/delete_expenses/'.$m, 'Delete', array('onClick' => "return confirm('Are you sure you want to delete?')"));
?>
</td>
</tr>
<?php echo $this->pagination->create_links()?>
</table>