Welcome Guest, Not a member yet? Register   Sign In
Help with pagination
#1

[eluser]ChaosKnight[/eluser]
Hi, I have a database with loads of results on each return, I want to use the pagination class but I'm still unsure about how it works, the user guide is a bit vague about it...

Here is my controller function:
Code:
function display($province)
{
    $query = $this->provinces_model->getProvince($province);
    $row = $query->row();
    $province_name = $row->province;
        
    $query = $this->provinces_model->getAccommodations($province);
    $rows = $query->num_rows();
    foreach($query->result() as $row)
    {
        $data['name'][] = $row->name;
        $data['name_id'][] = $row->name_id;
        $data['type'][] = $row->type;
        $data['location'][] = $row->location;
        if(strlen($row->description) > 100)
        {
            for($i=100;$i>=0;$i++)
            {
                if($row->description[$i] == ' ')
                {
                    $short_desc = substr($row->description,0,$i);
                    break;
                }
            }
            $short_desc .= "...";
            $data['description'][] = $short_desc;
        }
        else
        {
            $data['description'][] = $row->description;
        }
        $data['image1'][] = $row->image1;
    }
        
    $data['page_title'] = $province_name;
        
    $this->load->library('pagination');

    $config['base_url'] = base_url().'index.php/provinces/'.$province;
    $config['total_rows'] = $rows;
    $config['per_page'] = '5';

    $this->pagination->initialize($config);

    $this->load->view('header',$data);
    $this->load->view('nav');
    $this->load->view('sidebar');
    $this->load->view('province');
    $this->load->view('footer');
}

Here is my model function that is called in the controller:
Code:
function getAccommodations($province)
{
    $this->db->where('province_id',$province);
    $query = $this->db->get('accommodations');
    return $query;
}

As you can see I messed up with the pagination part, I really have no idea how to get started on it.. Any advice will be awesome...

Thanks


Messages In This Thread
Help with pagination - by El Forum - 06-21-2010, 01:31 PM
Help with pagination - by El Forum - 06-21-2010, 03:08 PM
Help with pagination - by El Forum - 04-17-2012, 07:27 PM
Help with pagination - by El Forum - 04-17-2012, 07:45 PM
Help with pagination - by El Forum - 04-17-2012, 10:23 PM
Help with pagination - by El Forum - 04-18-2012, 09:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB