Welcome Guest, Not a member yet? Register   Sign In
pagination not anchoring first link when on second page
#1

[eluser]vtatds[/eluser]
When I click on "2" in my pagination links, I get the results I'm expecting as far as data. But, "2" stays anchored and "1" is not anchored.

I have the following config for the pagination library in a controller:
Code:
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/benchmarks/view2/'.$benchmarkid.'/';
$config['total_rows'] = count($data['resultdatescount']);
$config['per_page'] = '5';
$this->pagination->initialize($config);
        
$data['benchmarks'] = $this->Benchmarks_model->getbenchmark($benchmarkid);
$data['resultdates'] = $this->Benchmarks_model->view_all_dates2($benchmarkid, $config['per_page'], $this->uri->segment(4,0)); //
$data['benchmarkresults'] = $this->Benchmarks_model->view_all2($benchmarkid, $config['per_page'], $this->uri->segment(4,0));
        
$this->load->view('header_view', $data);
$this->load->view('nav_view', $data);
$this->load->view('benchmarks_view_all2', $data);
$this->load->view('footer_view', $data);

and place this in my view:
Code:
echo $this->pagination->create_links();

now that i've finally got a query worked out, I can eliminate the view_all_dates2, but I don't see how that would cause this issue.
#2

[eluser]umefarooq[/eluser]
hi every beginner to CI is facing this problem with pagination just define in you config uri segment, by default uri segment is 3, check in your pagination segment

Code:
$config['uri_segment'] = 3;
#3

[eluser]vtatds[/eluser]
thanks, absolutely did it. i didn't consider that since i was sending the segment in the model calls.
#4

[eluser]PeterGreffen[/eluser]
@umefarooq: That did it for me too! Great & thanks!
#5

[eluser]amalik[/eluser]
Hi,
I tried that but it didnt worked for me Sad I have the same code as above but the uri segment for me is 4 as my url is www.mywebsite.com/blog/my_blog/view_blog/. All pages work except page no 1 any ideas?

Many Thanks in advance.
am




Theme © iAndrew 2016 - Forum software by © MyBB