title: Codeigniter MVC / Display all records in table
body: <p>The following code I wrote is only displaying the last row in the table. However I need to <code>loop</code> and display each <code>row</code> in the table.</p>
  <h1>MODEL</h1>
  <pre><code>class Catalog_products extends CI_Model {
  
      function Show_all_products()
      {
  
          $q = $this-&gt;db-&gt;get('printer');
         
          foreach ($q-&gt;result() as $row)
              {
                  $data = array();
                  $data['id'] = $row-&gt;id;
                  $data['name'] = $row-&gt;name; 
              }   
  
          return $data;
  
      }
      
  }
  </code></pre>
  <h1>VIEW</h1>
  <pre><code>&lt;?php echo $id ?&gt;
  &lt;?php echo $name ?&gt;
  </code></pre>
  <h1>CONTROLLER</h1>
  <pre><code>public function catalog()
  {
  
      $this-&gt;load-&gt;model('Catalog_products');
      $data = $this-&gt;Catalog_products-&gt;Show_all_products();
      $this-&gt;load-&gt;view('catalog', $data);
  }
  </code></pre>