0

SOLVED!

if I click page 2 that`s error:

Not Found The requested URL /rank/GetAll/30 was not found on this server.

My link is:

http://localhost/rank/GetAll/30

Model: Rank_Model

<?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

<?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"] = 3;

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

 $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 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

<?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

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

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

</tbody>
</table>

<p><?php echo $links; ?></p>

Maybe you know where is my problem?

Now I know where is my problem. In first page I have link:

http://localhost/index.php/rank/GetAll

But on the next:

http://localhost/rank/GetAll/30

In secend link, I don`t have index.php. How can I fix it?

In $config["base_url"] = base_url() . "rank/GetAll"; I add : $config["base_url"] = base_url() . "index.php/rank/GetAll";

And it`s ok :)

Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
praashaad
  • 25
  • 2
  • 8
  • How does the the url of page one look like? Are your rewrite rules working so that you can use the url without `index.php` in it? – air4x Oct 27 '12 at 09:53
  • http://localhost/index.php/rank/GetAll – praashaad Oct 27 '12 at 10:52
  • Now I know where is my problem. In first page I have link: http://localhost/index.php/rank/GetAll But on the next: http://localhost/rank/GetAll/30 In secend link, I don`t have index.php. How can I fix it? – praashaad Oct 27 '12 at 10:57
  • Try using [`site_url`](http://codeigniter.com/user_guide/helpers/url_helper.html) instead of `base_url` in the method `GetAll` in your Controller. – air4x Oct 27 '12 at 11:01
  • @marcin_poland - If you have solved your own problem, it's best to write a new answer detailing your fix. Don't forget to upvote any answers which were useful! – KatieK Nov 02 '12 at 18:58

2 Answers2

0

looking here $data["links"] = $this->pagination->create_links(); you have an array of links as your code says.

foreach( $data["links"] as $links)
    {?>
    <p><?php echo $links; ?></p>
    <?php }
Arun Killu
  • 13,581
  • 5
  • 34
  • 61
0

Try defining default value as $page=0 to GetAll() and remove assignment to the $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; and provide / after GetAll in url