i need fill in table in view data extracted database table. when tried this, returned error:
fatal error: call member function result_array() on non-object in c:\xampp\htdocs\bit\application\views\admin\add_new_room.php on line 32
view:
<table class="table table-hover"> <?php foreach ($query->result_array() $row): { ?> // line 32 <tr> <td><?php echo $row['room_number'];?></td> <td><?php echo $row['rt_name'];?></td> <td><?php echo $row['housekeeping_status'];?></td> </tr> <?php } ?> <?php endforeach; ?> </table>
controller:
function index() { $this->load->model('admin/edit_other_details'); $roomtype['rt_name'] = $this->edit_other_details->get_room_details(); $data['query'] = $this->edit_other_details->roomstable(); $tmp = array_merge($roomtype, $data); $this->load->view('/admin/add_new_room', $tmp); }
model:
function roomstable() { $query = $this->db->select(array('room_number','rt_name'))->get('rooms'); }
that because forgot return data in model.
try this
model
function roomstable() { $query = $this->db->select(array('room_number','rt_name'))->get('rooms'); return $query; //<---here }
Comments
Post a Comment