0
我的分頁不起作用。我正在使用codeigniter 2.1.4。我不明白什麼是問題,當我運行這個得到一個錯誤,如「未定義的財產:Crud :: $限制」。 PLZ幫助使用codeigniter的分頁不起作用
這裏是我的控制器:
public function index($offset = 0)
{
$data['title'] = "Basic CRUD Function With Codeigniter";
//echo "Done";
$offset = $this->uri->segment(3);
$records = $this->crud_mdl->get_paged_list($this->limit, $offset)->result();
$this->load->library('pagination');
$config['base_url'] = base_url().'/index/';
$config['total_rows'] = $this->crud_mdl->count_all();
$config['per_page'] = $this->limit;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
//$records = $this->crud_mdl->get_all_data();
$this->load->library('table');
$this->table->set_heading('ID','NAME','E-MAIL','PHONE','ACTION');
foreach ($records as $record) {
$this->table->add_row($record->id, $record->name, $record->email, $record->phone,
anchor('crud/viewCrud/'.$record->id,'view').' '.anchor('crud/editCrud/'.$record->id,'edit').' '.anchor('crud/delete/'.$record->id,'delete')
);
}
$data['table'] = $this->table->generate();
$this->load->view('crudlist',$data);
}
這裏是我的模型:
public function count_all()
{
return $this->db->count_all('test');
}
public function get_paged_list($limit = 4, $offset = 0)
{
return $this->db->get('test', $limit, $offset);
}
你在Crud控制器中聲明瞭$ limit作爲類變量嗎? – dikesh
仍然有問題我的分頁鏈接不工作,當我想要去第二個鏈接(2)像(1 2>)它顯示404錯誤。 –