Php 在Codeigniter中编辑多个字段
目前,编辑个人资料对我来说很有效。但是,我的问题是,只有一个元素被成功编辑。我可以回显以前保存的数据,甚至可以键入和编辑每个文本框。问题是,只有对profile字段所做的修改才能正确反映出来。所有其他字段保持不变 以下是我目前掌握的情况: 在控制器页面中:Php 在Codeigniter中编辑多个字段,php,codeigniter,submit,Php,Codeigniter,Submit,目前,编辑个人资料对我来说很有效。但是,我的问题是,只有一个元素被成功编辑。我可以回显以前保存的数据,甚至可以键入和编辑每个文本框。问题是,只有对profile字段所做的修改才能正确反映出来。所有其他字段保持不变 以下是我目前掌握的情况: 在控制器页面中: public function edit_profile() { //loads client profile and allows editing to be done $this->validateRole('cl
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);
}
我试图编辑我的控制器和模型页面只是为了得到错误,所以我现在评论添加的行。
我期待着任何可能的帮助
谢谢 错误可能是因为每次调用模型时,$data数组中有两个未定义的变量。在控制器中创建阵列,而不是在模型中创建阵列:
$data = array(
'tagline' => $_POST['tagline'],
'profile' => $_POST['profile'],
'billing_mode' => $_POST['billing_mode']
);
然后调用模型
$this->auth_model->edit_client_profile($this->auth_model->get_user_id(), $data);
从模型中删除阵列创建,将传递给$data的第二个参数更改为:
不要分别三次调用edit_client_profile。在控制器中创建一个包含键值“tagline”、“profile”和“billing_mode”的数组。然后将所有数据发送到您的“编辑客户端配置文件”功能。非常感谢!我得到了它!现在开始工作了!谢谢!但唯一的问题是,应该从下拉列表中选择的计费模式现在没有反映任何内容。。如果你也能帮我,我将不胜感激。。但我也会试试我的运气。再次感谢。祝你今天愉快;最好的办法可能是在下拉列表中查看codeigniter文档。很高兴有帮助……如果问题得到解决,请接受答案。再次感谢你的帮助!祝你今天愉快,丹尼尔丹尼尔,我的下拉功能现在很好用。谢谢你的帮助;
public function edit_client_profile($id, $data)
{
$this->db->where('id', $id);
$this->db->update('client', $data);
}