CodeIgniter Forums
pagination, next page not dispay - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: pagination, next page not dispay (/thread-55442.html)



pagination, next page not dispay - El Forum - 10-26-2012

[eluser]Martin_new[/eluser]
Hello, if I click page 2 that`s error:
Code:
Not Found
The requested URL /rank/GetAll/30 was not found on this server.

My link is:
Code:
http://localhost/rank/GetAll/30

Model: Rank_Model
Code:
<?php
Class Rank_Model extends CI_Model {
  
  public function __construct() {
   parent::__construct();
  }

  public function record_count() {
   return $this->db->count_all("ranking");
  }
  
  public function fifa_rank($limit, $start) {
   $this->db->limit($limit, $start);
   $query = $this->db->get("ranking");
  
   if ($query->num_rows() > 0) {
        foreach ($query->result() as $row) {
          $data[] = $row;
        }
        return $data;
      }
      return false;
   }
}

?>

Controller: Rank

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class rank extends CI_Controller {

function __construct()
{
   parent::__construct();
  $this->load->helper("url");
   $this->load->helper(array('form', 'url'));
   $this->load->model('Rank_Model','',TRUE);
  $this->load->library("pagination");
  
}

function GetAll() {
$config = array();
$config["base_url"] = base_url() . "rank/GetAll";
$config["total_rows"] = $this->Rank_Model->record_count();
$config["per_page"] = 30;
$config["uri_segment"] = 4;

$this->pagination->initialize($config);

$page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
$data["results"] = $this->Rank_Model->fifa_rank($config["per_page"], $page);
$data['errors_login'] = array();
$data["links"] = $this->pagination->create_links();
  
$this->load->view('left_column/open_fifa_rank',$data);
}
}

View Open: open_fifa_rank

Code:
<?php
$this->load->view('mains/header');
$this->load->view('login/loggin');
$this->load->view('mains/menu');
$this->load->view('left_column/left_column_before');
$this->load->view('left_column/menu_left');
$this->load->view('left_column/left_column');
$this->load->view('center/center_column_before');
$this->load->view('left_column/fifa_rank');
$this->load->view('center/center_column');
$this->load->view('right_column/right_column_before');
$this->load->view('login/zaloguj');
$this->load->view('right_column/right_column');
$this->load->view('mains/footer');
?>


and View: fifa_rank

Code:
<table>
<thead>
   <tr>
   <td>Pozycja</td>
   <td>Kraj</td>
   <td>Punkty</td>
   <td>Zmiana</td>
   </tr>
</thead>

&lt;?php
foreach($results as $data) {?&gt;
  <tbody>
   <tr>
   <td>&lt;?php print $data->pozycja;?&gt;</td>
   <td>&lt;?php print $data->kraj;?&gt;</td>
   <td>&lt;?php print $data->punkty;?&gt;</td>
   <td>&lt;?php print $data->zmiana;?&gt;</td>
   </tr>
&lt;?php } ?&gt;

</tbody>
</table>

<p>&lt;?php echo $links; ?&gt;</p>


Mayby you know where is my problem?


pagination, next page not dispay - El Forum - 10-26-2012

[eluser]CroNiX[/eluser]
Code:
$config["uri_segment"] = 4;
It looks like you are actually using segment 3 as the pagination offset


pagination, next page not dispay - El Forum - 10-26-2012

[eluser]Martin_new[/eluser]
I try with "uri_segment" = 3; and error it`s still that`s same.


pagination, next page not dispay - El Forum - 10-26-2012

[eluser]CroNiX[/eluser]
Did you change the other places where you are using uri:Confusedegment(4), like where you define $page?


pagination, next page not dispay - El Forum - 10-26-2012

[eluser]Martin_new[/eluser]
no, this is first time.


pagination, next page not dispay - El Forum - 10-26-2012

[eluser]CroNiX[/eluser]
Are you sure your model is even working when you load it like this:
Code:
$this->load->model('Rank_Model','',TRUE);

There is no 3rd parameter to load::model(). The 2nd parameter is the instance name if you decide to not use the default and you are setting it to an empty string.


pagination, next page not dispay - El Forum - 10-26-2012

[eluser]Martin_new[/eluser]
I change to:
Code:
$this->load->model('Rank_Model');

but it still this same problem.