php - Display $query->result(); -


i'm having trouble displaying results of query using foreach loop in codeigniter. heres controller:

function viewall() {     $this->load->model('all');     $data['query'] = $this->all->viewall();     $this->load->view('all', $data); } 

entire model file:

<?php class extends ci_model {  function insert_into_db() {     $data = array('error' => $this->input->post('f1'),                   'solution' => $this->input->post('f2')                  );     $this->db->insert('errors', $data); }  function viewall() {     $query = $this->db->select("error, solution")->from("errors")->get();     return $query->result(); } 

}

my view (where think problem is)

<table class="table table-striped">     <thead>         <tr>             <td><h3>error</h3></td>             <td><h3>solution</h3></td>         </tr>     </thead>     <tbody>         <?php foreach ($query->result_array() $entry) ?>         <tr>             <td><?php echo $entry->error; ?></td>             <td><?php echo $entry->solution;?></td>         </tr>         <?php endforeach ?>     </tbody> </table> 

controller:

function viewall() {     $this->load->model('all');     $data['results'] = $this->all->viewall();     $this->load->view('all', $data); } 

model:

function viewall() {     $query = $this->db->select("error, solution")->from("errors")->get();     return $query->result(); } 

view:

<table class="table table-striped">     <thead>         <tr>             <td><h3>error</h3></td>             <td><h3>solution</h3></td>         </tr>     </thead>     <tbody>         <?php foreach ($results $entry): ?>         <tr>             <td><?php echo $entry->error; ?></td>             <td><?php echo $entry->solution;?></td>         </tr>         <?php endforeach; ?>     </tbody> </table> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -