CodeIgniter Forums
Pagination Not working for me - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Pagination Not working for me (/showthread.php?tid=30385)



Pagination Not working for me - El Forum - 05-13-2010

[eluser]Arockia Raj[/eluser]
Hi,

I am new to CI.

I tried Pagination but i can't.

Plz any one help me.

My controller code

$this->load->library('pagination');
$per_page=3;

$config['base_url'] = base_url().'index.php/product/viewProduct/';
$config['total_rows'] = 9;
$config['per_page'] = 3;
$config['uri_segment'] = 3;
$config['num_links'] = 2;
$config['page_query_string'] = TRUE;
$config['first_link'] = 'First';
$config['last_link'] = 'Last';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';

$this->outputData['products'] = $this->user_model->getProducts($per_page, $this->uri->segment(3));
$this->pagination->initialize($config);

View code
&lt;? echo $this->pagination->create_links(); ?&gt;

If i tried the above code, in the browser i get the links like 1 2 3 >
if i click on 2 it redirect to the page http://localhost/pricebuster/index.php/product/viewProduct/&per_page=3 . but in this page there is no link for 1.
Also it showing same records as like page1.
Same problem for link 3.

Thanks in advance.

Regards,
Raj


Pagination Not working for me - El Forum - 05-14-2010

[eluser]pickupman[/eluser]
Try removing this line:
Code:
$config['page_query_string'] = TRUE;

Note: When posting code on the boards, please use the code button to wrap the code. This will help with syntax highlighting.


Pagination Not working for me - El Forum - 05-14-2010

[eluser]Arockia Raj[/eluser]
Hi,

Thank you for you reply.

But still the same problem exist.

Plz help any one to solve this issue


Arockia Raj


Pagination Not working for me - El Forum - 05-14-2010

[eluser]pickupman[/eluser]
How about
Code:
$config['base_url'] = site_url('product/viewProduct/');
  $config['total_rows'] = 9;  //Should make this dynamic
  $config['per_page'] = 3;
  $config['uri_segment'] = 3;
  $config['num_links'] = 2;
  $config['first_link'] = 'First';
  $config['last_link'] = 'Last';
  $this->pagination->initialize($config);

  $this->outputData['products']  =  $this->user_model->getProducts($per_page, $this->uri->segment(3,0));