0

controller

public function delete_data(){
    $this->load->model('test_model');

    $data['query']=$this->test_model->delete_data($id);

    $this->index();
}

model

public function delete_data($id)
    {
        $this->uri->segment(3);
        $this->db->where('id', $id);
        return $this->db->delete('test'); 
    }

view part

<a href="<?php echo site_url('test/delete_data/'. $row->id.'');?>">delete</a>
<a href="<?php echo site_url('test/edit_data/'. $row->id.'');?>">edit</a>
Qirel
  • 25,449
  • 7
  • 45
  • 62
gowtham
  • 1
  • 1

1 Answers1

2

you need to pass $id variable in delete_data() method in controller too. So method looks like:

public function delete_data($id){
    $this->load->model('test_model');

    $data['query']=$this->test_model->delete_data($id);

    $this->index();
}

There is no defined variable $id within method's scope, router passes it as argument, but you need to pass it to method.

Nikola Kirincic
  • 3,651
  • 1
  • 24
  • 28