My pagination is not working. I am using codeigniter 2.1.4. I dont understand what's the problem when i run this get an error like " Undefined property: Crud::$limit". Plz help

Here is my controller:

    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);
    }

Here is my Model:

    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);
    }
有帮助吗?

解决方案

Is variable $limit in class Crud declared and defined? Try to add this to corrent controller Crud.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top