2014-01-15 83 views
1

我在我的codeigniter應用程序中使用分頁類。分頁鏈接顯示正常,也就是說,我想正確的鏈接數量,例如。 1 2 3 4 5>,頁面加載我每頁指定的條目數量。CodeIgniter分頁鏈接不工作

錯誤是當我點擊其中一個鏈接轉到下一組條目時,它顯示「無法找到頁面」。

控制器:

public function index() 
    { 

     $config["base_url"] = base_url().'tester'; 

      $config["total_rows"] = $this->test_model->count_entries(); 

      $config["per_page"] = 3; 

      $config['uri_segment'] = 2; 

      $config["num_links"] = 10; 

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

     $page = ($this->uri->segment(2)) ? $this->uri->segment(2) : 0; 
     $q1=$this->test_model->get_entries($config["per_page"],$page); 
      $links = $this->pagination->create_links(); 
} 

的型號:

public function count_entries() { 

     $this->db->where('approved', 0); 
     $this->db->from('tested'); 

     return $this->db->count_all_results(); 

    } 

public function get_entries($limit, $start) 
    { 
     $this->db->limit($limit, $start); 

     $this->db->where('approved', 0); 

$q = $this->db->get('tested'); 
$data = $q->result_array(); 
     return $data; 
    } 

頁面的URL是http://localhost:8080/CIAPP/tester,與http://localhost:8080/CIAPP/設置爲我在我的配置文件BASE_URL。 CIAPP是應用程序目錄,tester是我的控制器。

發生錯誤時,我點擊任何分頁鏈接到url http://localhost:8080/CIAPP/tester/3其中說「頁面未找到」。

當我點擊鏈接2時,網址是/ 3,當我點擊鏈接3時,網址是/ 6。我想這是因爲我每頁指定了3個。

我該如何解決這個問題,以便當我點擊分頁鏈接時,具有相應條目的頁面加載?

回答

3

CIAPP - 應用程序目錄

您使用的內部測試的任何功能 tester-控制器類..?

if then,

base_url('。'test/function_name';

+0

是的,它是笨的應用程序目錄,如果您使用的是內部測試的任何功能,包括在URL測試儀是我的控制器 – Tester

+0

。 BASE_URL() '測試器/函數名'。 – Pradeep

+0

我正在使用索引函數和一個其他函數。但是它是索引函數加載條目並設置分頁 – Tester

2

您打算在分頁配置中將「use_page_numbers」值設置爲TRUE。

$config['use_page_numbers'] = TRUE,