Welcome Guest, Not a member yet? Register   Sign In
Pagination Not working for me
#1

[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/p...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
#2

[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.
#3

[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
#4

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




Theme © iAndrew 2016 - Forum software by © MyBB