Welcome Guest, Not a member yet? Register   Sign In
Pagination link error
#1

[eluser]agdelacruz02[/eluser]
Hi, I'm currently working on pagination of query results in my view functionality. I manage to create the pagination links but I encounter an error when I clicked on the next page. The error was "The requested URL /2 was not found on this server". My controller goes like this

Code:
class User extends CI_Controller {

public function __construct()
{
  parent::__construct();
  $this->load->model( 'user_model' );
     $this->load->library("pagination");
  
}
        public function index()
{
  $config = array();
  $config['total_rows'] = $this->user_model->record_count();
  $config['per_page'] = 2;
  $config["uri_segment"] = 3;
  $choice = $config["total_rows"] / $config["per_page"];
  $config["num_links"] = round($choice);
  $this->pagination->initialize($config);
  $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
  $data["results"] = $this->user_model->get_query_species($config["per_page"], $page);
  $data["links"] = $this->pagination->create_links();
  
  $this->load->view('home', $data);
  
}
}

Could someone help me with this?? tnx..
#2

[eluser]Samus[/eluser]
$config["uri_segment"] = 3;

You're not passing any arguements into your index() method, so change that to 2.

$config["uri_segment"] = 2;
#3

[eluser]agdelacruz02[/eluser]
Hi, I've tried changing it to
Quote:$config["uri_segment"] = 2;
but the error message is still the same
Quote:The requested URL /2 was not found on this server.
. Tnx for the reply.
#4

[eluser]Samus[/eluser]
Does it work if you view it from siteurl/index/2 ?
#5

[eluser]agdelacruz02[/eluser]
It also didn't work.. I also try to add
Code:
$config['base_url'] ='http://localhost/MAKIBIS3.1/';
and
Code:
$config['base_url'] ='http://localhost/MAKIBIS3.1/index.php';
on the index function of my controller but neither of it solve my problem
#6

[eluser]Samus[/eluser]
Change your config back to the first one and try the URL with siteurl/index/2

The pagination is expecting yor 2nd parameter to be the segment in used in displaying pagination results.

In your case the first parameter is the pagination segment.

If you want the following URL siteurl.com/2 your $config['uri_segment'] should be set to the first parameter i.e $config['uri_segment'] = 1.

It's more practical to use the third or second parameter in your apps, so either link it to siteurl.com/index/2 or use a different function for your pagination




Theme © iAndrew 2016 - Forum software by © MyBB