なぜ機能しないのかわかりません。多くの記事をたどりましたが、コードが完全に間違っているようです。すべてを消去する必要があります。そうしないと。
これは私のコントローラーです
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()?>