2
我想從控制器傳遞多個參數到我的模型。看起來,我正在嘗試通過的$scholId
在我提交表單後不會通過模型。但是,$userId
只能通過數據庫。 $this->uri->segment(4)
有什麼問題不能正確傳遞?Codeigniter - 傳遞多個參數
function apply()
{
$this->load->helper('form');
$this->load->library('form_validation');
$scholId = $this->uri->segment(4);
$userId = '2'; //User query -> this will be taken from session
$this->data['scholarship'] = $this->scholarship_model->getScholarship($scholId);
$this->data['title'] = "Apply";
$this->form_validation->set_rules('essay', 'Essay', 'required');
if ($this->form_validation->run() === FALSE)
{
$this->load->view('templates/header', $this->data);
$this->load->view('student/page_head', $this->data);
$this->load->view('student/form', $this->data);
$this->load->view('templates/footer', $this->data);
}else{
// Validation passes
$this->users_model->applySchol($userId,$scholId);
redirect('/scholarships');
}
}
當您提交表單段將不會有任何值 –
您可以在提交之前做var_dump($ schoId)並將其發佈到此處嗎? –
確保您獲得了正確的細分。控制器是1,功能是2等。不計算基地網址(顯然我認爲這種排序)你可以顯示一個示例URL不工作?做什麼mamdouh說轉儲它,如果它沒有返回你的想法或任何嘗試將其改爲3。 –