0

I am getting an error in my code and don't know why. Here is the error :

Fatal error: Call to undefined method Display::index() in 

Here is the controller part that causes the error:

 function delete(){
     $this->load->model('display_model');
     $this->display_model->delete_row();
     $this->index();

 }

and model part if needed just in case:

function delete_row()
          {
             $this->db->where('QID', $this->uri->segment(3));
             $this->db->delete('tblquestions');
          }
0

1 Answer 1

2

Instead you can do like below:

function delete(){
     $this->load->model('display_model');
     $this->display_model->delete_row();
     redirect('/controllerName/', 'refresh');
 }

The benefit of redirect is that you can set some message to user that you completed or failed to do action by passing some id.

function delete(){
     $this->load->model('display_model');
     $this->display_model->delete_row();
     redirect('/controllerName/index/1', 'refresh');
 }
Sign up to request clarification or add additional context in comments.

4 Comments

it fixed the error but it dose not delete the selected row in the table
can u explain more i am new to this daunt really understand what u said ?
just put "$this->output->enable_profiler(TRUE);" in your controller so that it will print the query at the bottom of the page(in browser).
i fixed with the redirect tnx for your help i had a type :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.