最后我的分页工作了。仍然存在一些问题。在每个页面中它只显示一个数据和编辑删除功能不起作用。我尝试更改几乎所有内容。任何指导都会很棒。 *这是我的控制器*
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);
}
这是我模型中的代码
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();
}
这就是视图
<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>