我不知道为什么它不起作用。我关注了很多文章,但似乎我的代码完全错误,我需要删除所有东西。<<1,2,3>>这个标志来了,但是当我点击任何东西时,只有 url chng 什么也没发生别的。
这是我的控制器
function view($offset=0){
$limit=5;
//$this->uri->segment(3);
$this->load->model('emp_expenses_model');
//$result['contents']=$this->emp_expenses_model->getRows($limit,$offset);
$result['countRows']=$this->emp_expenses_model->countRows();
$this->load->library('pagination');
$this->load->library('table');
$config=array(
'base_url' =>site_url ('/view_expenses/view?'),
'total_rows' => $result['countRows'],
'per_page' => $limit,
'uri_segment' => 3,
//'num_links' => 200,
);
//var_dump($config);
$this->db->limit('5');
$this->pagination->initialize($config);
$this->load->model('emp_expenses_model');
$this->data['view_expenses'] = $this->emp_expenses_model->get_all();
//$this->data['pagination'] = $this->pagination->create_links();
//var_dump($this->data['pagination']);die("jk");
$this->data['title'] = 'Payroll System';
$this->data['message'] = $this->session->flashdata('message');
$this->load->library('pagination');
$this->load->view('view_expenses', $this->data);
/*$this->load->view('add_list', $this->data);*/
}
这是我的模型
<?php
class Emp_expenses_model extends CI_Model
{
function emp_expenses_model()
{
parent::__construct();
}
function get_all()
{
$this->db->select('expenses_id,id,dropdown,modeofpayment,amount');
$query=$this->db->get('emp_expenses');
return $query->result_array();
}
function get_record($list_id)
{
$this->db->select('expenses_id,id, dropdown, modeofpayment, amount');
$this->db->where('id',$list_id);
$query=$this->db->get('emp_expenses');
return $query->result_array();
}
function insert_list($data)
{
$this->db->insert('emp_expenses', $data);
$id = $this->db->insert_id();
return (isset($id)) ? $id : FALSE;
}
public function update_list($list_id, $data)
{
$this->db->where('id', $list_id);
$this->db->update('emp_expenses', $data);
}
public function del_list($list_id)
{
$this->db->where('id', $list_id);
$this->db->delete('emp_expenses');
}
function getRows($limit,$offset)
{
$query=$this->db->select('expenses_id,id,dropdown,modeofpayment,amount')
->from('emp_expenses')
->limit($limit,$offset);
$result=$query->get()->result_array();
return $result;
//var_dump($result);
}
function countRows()
{
//$query="select count(*) as count from emp_expenses";
$result = $this->db->count_all_results('emp_expenses');
//$result=$this->db->query($query);
return $result;
//var_dump('countRows');
}
并且在我正在写的表格内 *
<?php echo $this->pagination->create_links()?>