當前,編輯配置文件適用於我。但是,我的問題是,只有一個元素被成功編輯。我可以回顯以前保存的數據,我甚至可以鍵入和編輯每個文本框。問題是,只有在「配置文件」字段上進行的修改才能得到適當的反映。所有其他領域保持不變。在Codeigniter中編輯多個字段
這裏是我到目前爲止有: 在控制器頁:
public function edit_profile()
{
//loads client profile and allows editing to be done
$this->validateRole('client');
$this->load->model('job_model');
$id = $this->auth_model->get_user_id();
$data['client'] = $this->auth_model->get_client($id);
$this->load->view('client/edit_profile', $data);
}
public function edit_profile_submit()
{
$this->validateRole('client');
$this->load->model('auth_model');
//$this->auth_model->edit_client_profile($this->auth_model->get_user_id(), $_POST['tagline']);
$this->auth_model->edit_client_profile($this->auth_model->get_user_id(), $_POST['profile']);
//$this->auth_model->edit_client_profile($this->auth_model->get_user_id(), $_POST['billing_mode']);
redirect('client/view_profile?message=Profile updated.');
}
模型頁:
public function edit_client_profile($id, $profile)
{
// allows client to edit his or her profile
$data = array(
//'tagline' => $tagline,
'profile' => $profile
//'billing_mode' => $billing_mode
);
$this->db->where('id', $id);
$this->db->update('client', $data);
}
我試圖編輯我的控制器和模型頁面,讓我評論了只得到錯誤現在改爲添加行。 我期待着任何可能的幫助。
謝謝!
不要分別調用edit_client_profile三次。在您的控制器中創建一個包含鍵值'tagline','profile'和'billing_mode'的數組。然後將所有數據發送到您的edit_client_profile函數。 – Dan