我试图提交一个编辑表格,编辑用户的学术细节,这些细节在数据库中有唯一的id和我的代码在简短的代码如下:
class edit extends ci_controller
{
function user_academics($id = NULL)
{
if(isset($id) == FALSE) //if link is ./edit/user_academics
{
$id = NULL;
$link = site_url('profile');
show_error("Invalid Page Request! <a href='$link' Go to Profile </a>");
}
$user_id = $this->session->userdata('user_id');
$data['fill'] = $this->edit_model->get_user_academics($id);
if($user_id != $data['fill']['user_id']) // check if logged in user is accessing his record or others
{
$link = site_url('profile');
show_error("This is an Invalid Request ! <a href='$link'>Go to Profile </a>");
}
else // actual work starts here
{
$this->session->set_flashdata('ua_id',$id); // update_academics will get this data
$this->load->view('edit/edit_3_view',$data);
}
}
function update_academics()
{
$ua_id = $this->session->flashdata('ua_id'); // flash data used here .
if( !$ua_id )
{
show_error('Sorry, This request is not valid!');
}
$academics = array(
// All post values
);
$this->edit_model->update_user_academics($academics,$ua_id);
//print_r($academics);
redirect('profile');
}
}现在的问题是-如果我打开两个不同的记录进行编辑,那么它将只设置一个会话闪存值。-无论我编辑什么,最后一个闪存值的现有值都会更新。如果我在上面的代码中错了,请给我建议另一种方式或纠正我。谢谢
发布于 2013-01-25 15:27:08
将flashdata保存在数组中,如下所示:
$myArr = array('value 1', 'value 1');
//set it
$this->session->set_flashdata('some_name', $myArr);在视图中:
$dataArrs = $this->session->flashdata('some_name');
//loop thru $dataArrs to show the flashdatahttps://stackoverflow.com/questions/14517069
复制相似问题