title: Invalid argument supplied for foreach() in Codeigniter
body: <p>I am getting error message: Invalid argument for foreach() in my View. I wanted to display all entries in my mysql table but i kept on getting error message. I am a newbie in Codeigniter and couldn't really figure out how to solve this. The codes are the following:
  My model (display_branch.php)</p>
  
  <pre><code>&lt;?php if(!defined ('BASEPATH')) exit ('No direct script access allowed');
  class Display_Branch extends CI_Model
  {
  function __construct()
  {
      parent::__construct();
  }
  
  public function getAll()
  {
      $this-&gt;db-&gt;select('bcode, bname, btel, badd');
      $this-&gt;db-&gt;from('branches');
  
      $query = $this-&gt;db-&gt;get();
  
      if($query-&gt;num_rows() == 1)
      {
          $results = $query-&gt;result();
          return $results;
      }
      else
      {
          return FALSE;
      }
  }
  }?&gt;
  </code></pre>
  
  <p>My Controller (link_controller.php) *only the snippet.</p>
  
  <pre><code>public function insert()
  {
      $this-&gt;load-&gt;model('display_branch');
  
      $data['results'] = $this-&gt;display_branch-&gt;getAll(); 
  
      $this-&gt;load-&gt;view('insert_branch');
      $this-&gt;load-&gt;view('navigation');
      $this-&gt;load-&gt;view('content_bc', $data);
      $this-&gt;load-&gt;view('footers');
  }
  </code></pre>
  
  <p>And my view(content_bc.php)</p>
  
  <pre><code>&lt;?php
  
  
          foreach($results as $row)
          {
              echo '&lt;tr&gt;';
              echo '&lt;td&gt;'.$row-&gt;bcode.'&lt;/td&gt;';
              echo '&lt;td&gt;'.$row-&gt;bname.'&lt;/td&gt;';
              echo '&lt;td&gt;'.$row-&gt;btel.'&lt;/td&gt;';
              echo '&lt;td&gt;'.$row-&gt;badd.'&lt;/td&gt;';
              echo '&lt;/tr&gt;';
          }
  
  ?&gt;
  </code></pre>
  
  <p>Please help me what to do. Thank you.</p>