redirect uri segment after delete

791 views Asked by At

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

when I want delete the data and to direct to the url such as the example above

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

There are 3 answers

6
Abdulla Nilam On

Use session

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

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

then in next method

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

Use

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

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