当前,编辑配置文件适用于我。但是,我的问题是,只有一个元素被成功编辑。我可以回显以前保存的数据,我甚至可以键入和编辑每个文本框。问题是,只有在“配置文件”字段上进行的修改才能得到适当的反映。所有其他领域保持不变。在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