title: Passing data from Controller to View with CodeIgniter
body: <p>I'm having difficulty with display data from the db to dropdown.</p>
  
  <p>This is what I have tried:</p>
  
  <p><strong>form_model.php</strong></p>
  
  <pre><code>function getEmployee()
   {
      $this-&gt;db-&gt;select('username');
      $query = $this-&gt;db-&gt;get('tbl_usrs');
  
      return $query-&gt;result();
   } 
  </code></pre>
  
  <p><strong>form_controller.php</strong></p>
  
  <pre><code>public function evaluate()
  {
      $data['employee'] = $this-&gt;form_model-&gt;getEmployee();
      $this-&gt;load-&gt;view('evaluate_view');
  }
  </code></pre>
  
  <p><strong>evaluate_view.php</strong></p>
  
  <pre><code>&lt;select class="form-control"&gt;
     &lt;?php
         foreach($employee as $row)
         {
           echo '&lt;option value="'.$row-&gt;username.'"&gt;'.$row-&gt;username.'&lt;/option&gt;';
         }
     ?&gt;
   &lt;/select&gt;
  </code></pre>
  
  <p>It's giving me an error saying I have an unidentified variable employee in my view file. I've seen problems relating to this but so far all their solutions didn't work for me.</p>