Edvinas Liutvaitis
Edvinas Liutvaitis

Reputation: 575

Pagination function not working

Hi everyone can someone explain what dose this do

$this->uri->segment());

its part of my pagination function and I cant figure out why I need it and if there is something to replace it with. Its causing an error in my script. Thanx for ur help. Also im new to codeigniter and php plys try to make it simple form me tnx in advance.

error message

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: views/survay_view.php

Line Number: 31

here is my all code for my pagination function

//pagination
        function page()
           {

            $this->load->library('pagination');


            $config['base_url'] = 'http://localhost/admin/index.php/survay/';
            $config['total_rows'] = $this->db->get('save_survay')->num_rows();

            $config['per_page'] = 1;
            $config['num_links'] =10;

            $this->pagination->initialize($config);
            //print_r($this->uri->segment());die;

            $data['records'] = $this->db->get('save_survay', $config['per_page'], $this->uri->segment());
            $data['pagination'] = $this->pagination->create_links();
            $this->load->view('survay_view', $data);

          }
    }

Upvotes: 0

Views: 308

Answers (2)

christian.thomas
christian.thomas

Reputation: 1122

The variable $this->uri->segment(); means a particular URI segment.

So for example if you have a URL /page/view/1

If you did echo $this->uri->segment(2); it would return 'view'.

See http://ellislab.com/codeigniter/user-guide/libraries/uri.html for further information.

Upvotes: 1

Ripa Saha
Ripa Saha

Reputation: 2540

this $this->uri->segment(); is actually pick up the value from url. just like $_GET[]. see http://ellislab.com/codeigniter/user-guide/libraries/uri.html for details help.

Upvotes: 0

Related Questions