Welcome Guest, Not a member yet? Register   Sign In
Pagination Problem - working with models
#1

[eluser]Jeff Logan[/eluser]
I've been trying to implement pagination with a few problems.

Here's my controller. Is the problem because I load the model first (which I need to do as it has the num_rows count in a function)?
Code:
function index()
    {
        
        $this->load->model('Phone_data');
        
        // load pagination class
        $this->load->library('pagination');
        $config['base_url'] = base_url().'index.php/test/';
        $config['total_rows'] = $this->Phone_data->get_index_phones_count();    
        $config['uri_segment'] = '2';
        $config['per_page'] = '10';
           $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';
        
        $this->pagination->initialize($config);

        $data['title'] = "index";
        $data['heading']="heading - index";
        
        //get menu data
        $data['make'] = $this->Phone_data->get_all_makes();
        $data['net'] = $this->Phone_data->get_all_networks();
        
        //get main data - pagination
        $data['phones'] = $this->Phone_data->get_index_phones($config['per_page'],$this->uri->segment(2,0));
        
        //load page view
        $this->load->view('phoneview', $data);
        
        
        //display page info
        $this->output->enable_profiler(TRUE);
    }

All the other parts of my code are fully working as expected. Can anyone else see an error in my coding?

My other controllers are basically the same as above, except they use 'segment(4,0)' has anyone got any advice when using the pagination class.


Thanks
#2

[eluser]Jeff Logan[/eluser]
This has been resolved... the pagination class was working. I made a mistake in the 'counting of rows' so it was returning zero... and therefore no pagination was shown!




Theme © iAndrew 2016 - Forum software by © MyBB