我创建了一个项目,我有一个关于直接网址段的问题......
例如: 这是我的网址
http://10.88.25.131/instrumentdev/instrument/instrument/detail/CT-BSC-001
当我想要删除数据并指向网址时,例如上面的例子
这是我的控制器
public function detail(){
$id = $this->uri->segment(4);
$data = array(
'detail'=>$this->mcrud->get_detail($id),
'lihat' =>$this->mcrud->lihat_komentar($id),
'isi' =>'instrument/read_views');
$this->load->view('layout/wrapper', $data);
}
function deletecom() {
$u = $this->uri->segment(4);
$this->mcrud->deletecomment($u);
redirect('???**this my problem**???');
}
答案 0 :(得分:1)
使用会话
$newdata = array(
'data' => $u
);
$this->session->set_userdata($newdata);
redirect('controller/method');
然后在下一个方法
$u = $this->session->userdata('data');
答案 1 :(得分:0)
使用
$this->load->helper('url');/*if not already*/
redirect(base_url('controller/method/parametersIfAny'));
答案 2 :(得分:0)
尝试这个:
function deletecom() {
echo $this->uri->segment(4);die(); //what does this print ??
$u = $this->uri->segment(4);
$this->mcrud->deletecomment($u);
redirect(base_url('instrument/instrument/detail/'.$u));
}