简体   繁体   English

删除后重定向uri段

[英]redirect uri segment after delete

I created a project , I have a question about the direct url segment ... 我创建了一个项目,我对直接网址段有疑问...

For example: this my URL 例如:这是我的网址

http://10.88.25.131/instrumentdev/instrument/instrument/detail/CT-BSC-001 http://10.88.25.131/instrumentdev/instrument/instrument/detail/CT-BSC-001

when I want delete the data and to direct to the url such as the example above 当我想要删除数据并直接指向url时,例如上面的示例

this my controllers 这是我的控制器

    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**???');
   }    

Use session 使用会话

$newdata = array(
    'data'  => $u
);

$this->session->set_userdata($newdata);
redirect('controller/method');

then in next method 然后在下一个方法

$u = $this->session->userdata('data');

Use 采用

$this->load->helper('url');/*if not already*/
redirect(base_url('controller/method/parametersIfAny'));

TRY this : 尝试这个 :

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));
   } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM