php - Redirecting the previous page after deleting a record -
i'm newbee in ci. i'm hoping can me problem. :) trying redirect previous page in site has table containing data database. keep on getting message
fatal error: call member function result() on non-object in c:\xampp\htdocs\..... call member function result() on non-object in c:\xampp\htdocs\findiningcebu.com\application\views\admin\searchrestodisplay.php on line 122
and notice says
undefined variable: restaurantinfo....backtrace: file: c:\xampp\htdocs\findiningcebu.com\application\views\admin\searchrestodisplay.php line: 122
here codes:
view:
<div class = "list"> <table border=2> <tr style="font-size: 16px; background-color: rgba(26, 26, 38, 0.5);"> <th>name</th> <th>logo</th> <th>cuisine</th> <th>action</th> </tr> <?php $restoname= ''; $restologo= ''; $cuisine= ''; foreach($restaurantinfo->result() $row) { $restoname= $row->restoname; $restologo= $row->restologo; $cuisine= $row->cuisine; ?>
controller:
public function delete($id) { $this->load->model('adminmodel'); $delete = $this->adminmodel->delete($id); $this->load->view('admin/searchrestodisplay'); } public function searchresto() { $restoinfo = $_post['restoinfo']; $searchinfo = $_post['searchinfo']; $this->load->model('adminmodel'); $restaurantinfo['restoinfo'] = $restoinfo; $restaurantinfo['searchinfo'] = $searchinfo; $restaurantinfo['restaurantinfo']=$this->adminmodel->searchrestaurant($restoinfo,$searchinfo); $this->load->view('admin/searchrestodisplay',$restaurantinfo); }
model:
public function delete($id){ $this->db->delete('restaurants',array('id'=>$id)); }
this happening because result()
method of database class , trying use method on $restaurantinfo
, looks simple array.
i recommend $this->adminmodel->searchrestaurant
returns this
function searchrestaurant(){ /*stuff*/ return $query->result_array(); }
this way can foreach on view
foreach($restaurantinfo $row) { $restoname= $row['restoname']; $restologo= $row['restologo']; $cuisine= $row['cuisine']; }
the problem looks trying use method of database class on view, query not exists.
so, change searchrestaurant
function, or query on view.. thing don't recommend...
hope helps
Comments
Post a Comment