Home Ask Login Register

Developers Planet

Your answer is one click away!

QueenR February 2016

Redirecting the previous page after deleting a record

I'm a newbee in CI. I'm hoping that you can help me with my problem. :) I am trying to redirect the previous page in my site which has the table containing the data from the database. I keep on getting the message

Fatal error: Call to a member function result() on a non-object in C:\xampp\htdocs\..... 
Call to a member function result() on a non-object in C:\xampp\htdocs\findiningcebu.com\application\views\admin\SearchRestoDisplay.php on line 122

and the notice that says

Undefined variable: restaurantinfo....Backtrace:    
File: C:\xampp\htdocs\findiningcebu.com\application\views\admin\SearchRestoDisplay.php
Line: 122

Here are my codes:


<div class = "list">
<table border=2>
<tr style="font-size: 16px; background-color: rgba(26, 26, 38, 0.5);">

      $restoname= ''; 
      $restologo= '';
      $cuisine= '';

      foreach($restaurantinfo->result() as $row) 
        $restoname= $row->restoname; 
        $restologo= $row->restologo;
        $cuisine= $row->cuisine;


public function delete($id)
    $delete = $this->AdminModel->delete($id);

 public function searchresto()
    $restoinfo = $_POST['restoinfo'];
    $searchinfo = $_POST['searchinfo'];

    $restaurantinfo['restoinfo'] = $restoinfo;
    $restaurantinfo['searchinfo'] = $searchinfo;


public function delete($id)        


David Bm February 2016

This is happening because result() is a method of the database class and you are trying to use this method on your $restaurantinfo and this looks like a simple array.

I recommend you that your $this->AdminModel->searchrestaurant returns something like this

 function searchrestaurant(){
   return $query->result_array(); 

this way you can simply foreach this on your view

foreach($restaurantinfo as $row) 
        $restoname= $row['restoname']; 
        $restologo= $row['restologo'];
        $cuisine= $row['cuisine'];

The problem looks like you are trying to use a method of the database class on your view, where your query does not exists.

So, change the searchrestaurant function, or do the query on the view.. thing that I don't really recommend...

Hope that helps

Sharmistha Das February 2016

In your delete function when you load the view, you don't pass the value '$restauranrinfo' that's why the restaurant details is missing in view. Fetch the restaurant details from database before load the view and pass the value in view.

Post Status

Asked in February 2016
Viewed 3,988 times
Voted 6
Answered 2 times


Leave an answer

Quote of the day: live life