2016-08-31 11 views
0

インデックスページはうまくいきますが、ページ2をクリックすると404ページが見つかりません。codeigniterページネーション次のページ404が見つかりません

コントローラ

public function index() { 
    $config = array(); 
    $config['base_url'] = base_url('admin/booking'); 
    $total_row = $this->booking_m->record_count(); 
    $config["total_rows"] = $total_row; 
    $config["per_page"] = 1; 
    $config['use_page_numbers'] = TRUE; 
    $config['num_links'] = $total_row; 
    $config['cur_tag_open'] = '&nbsp;<a class="current">'; 
    $config['cur_tag_close'] = '</a>'; 
    $config['next_link'] = 'Next'; 
    $config['prev_link'] = 'Previous'; 

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

    if($this->uri->segment(3)){ 
    $page = ($this->uri->segment(3)) ; 
    } 
    else{ 
    $page = 1; 
} 


    $data["info"] = $this->booking_m->fetch_data($config["per_page"], $page); 
    $str_links = $this->pagination->create_links(); 
    $data["links"] = explode('&nbsp;',$str_links); 


    $this->load->view('admin/booking/index',$data);} 

ページのURLは、それが動作http://127.0.0.1/admin/booking/1です。

http://127.0.0.1/admin/booking/2は// inspect-を使用することにより、エラー

モデル

public function fetch_data($limit, $id) { 
$this->db->limit($limit); 
$this->db->where('id', $id); 
$query = $this->db->get("booking"); 
if ($query->num_rows() > 0) { 
    foreach ($query->result() as $row) { 
    $data[] = $row; 
    } 

    return $data; 
} 
return false; 
} 

答えて

2

を試してみてください、あなたが

$route['admin/booking/(:any)'] = 'controllername/function/$1'; 

https://www.codeigniter.com/user_guide/general/routing.html?highlight=routes

を試していない場合はあなたのベースURLが

ようになっているはずのルートを設定しています
| http://example.com/ 
| 
| WARNING: You MUST set this value! 
| 
| If it is not set, then CodeIgniter will try guess the protocol and path 
| your installation, but due to security concerns the hostname will be set 
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise. 
| The auto-detection mechanism exists only for convenience during 
| development and MUST NOT be used in production! 

$config['base_url'] = 'http://localhost/yourproject/'; 

あなたのURL内のIPアドレスを持っている場合、一部のリンクが動作しない場合があり、そのURLを設定し、代わりにIP

のlocalhostを使用するのが良い理由も

説明したように、クラス名とファイル名のためにはucfirst道をたどることを確認してくださいここでhttps://www.codeigniter.com/user_guide/general/controllers.html#let-s-try-it-hello-world

0

が見つかりません>要素は、2番目のページがリダイレクトされるURLをご確認ください。..

1

あなたは設定を逃しました。代わりに、この設定$config['use_page_numbers'] = TRUE;の設定に

$config['uri_segment'] = 3; 

それを置き、

+0

はいベースURLを変更します$ config ['base_url'] = base_url( 'l0gadmin/booking/index');あなたのコード。今、私はOKページはうまくいっていますが、ページ2はデータを表示していません。私のモデル機能をチェックしてください。 –

+0

あなたの今の問題は何ですか? –

関連する問題