นี่คือชั้นเรียนของฉัน:
class Pacients extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('email');
$this->load->library('session');
$this->load->library('pagination');
$this->load->model('pacient_model');
$this->load->model('department_model');
}
public function index(){
$id_doctor = $this->session->userdata('userid');
$department = $this->department_model->get_department_by_doctor($id_doctor); // get deparmentd_id
$diagnostics = $this->department_model->get_diagnostics($department[0]->department_id); // get diagnostics by using deparment id
$department_data = $this->department_model->get_department_by_id($department[0]->department_id); // get all info about deparment
//start pagination
if ($this->uri->segment(2) == null || $this->uri->segment(2) == ""){
$limit = 0;
}else{
$limit = $this->uri->segment(2);
}
$get_pacients = $this->pacient_model->get_pacients_by_doctor($id_doctor, $limit);
$total = $this->pacient_model->get_total_pacients_by_doctor($id_doctor);
$config['base_url'] = base_url().'pacients';
$config['total_rows'] = $total[0]->total;
$config['per_page'] = 3;
$this->pagination->initialize($config);
// end pagination
$data = array(
'pacients' => $get_pacients,
'diagnostics' => $diagnostics,
'department_data' => $department_data
);
if (!$diagnostics){// check if there any diagnostic in db associated to the current department
$data['error'] = 1;// if it is 1 then a form will apears in the view
}
$this->load->view('frontend/common/header');
$this->load->view('frontend/pacients',$data);
$this->load->view('frontend/common/footer');
}
}
ในตัวแปร get_pacients ฉันมีผลลัพธ์ทั้งหมดและได้ผลลัพธ์ที่ต้องการทั้งหมด ในมุมมองแสดงการแบ่งหน้าให้ฉันดู แต่เมื่อฉันคลิกที่หน้า 2 มันแสดงหน้า 404 มันแปลกที่ในอีกหน้าหนึ่งฉันใช้การใช้การแบ่งหน้าแบบเดียวกันและใช้งานได้ URL ดูเหมือนว่า:
http://localhost/licenta/pacients
คุณรู้ไหมว่าทำไมฉันถึงได้รับ 404 ฉันใช้ Codeigniter 3 ขอบคุณล่วงหน้า
$this->uri->segment(3);
และ base_url เป็น$config['base_url'] = base_url().'pacients/index';
codeigniter ที่ชาญฉลาดอื่น ๆ จะพยายามโหลดเมธอดซึ่งเป็นตัวแปรการแบ่งหน้าของคุณจริงๆ - person Kamran   schedule 03.05.2015