title: display data from database to dropdown 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>Model.php</strong></p>
  
  <pre><code>        public function __construct()
          {
              parent::__construct();
          }
  
          function getAllGroups()
          {
              /*
              $query = $this-&gt;db-&gt;get('location');
  
              foreach ($query-&gt;result() as $row)
              {
                  echo $row-&gt;description;
              }*/
  
              $query = $this-&gt;db-&gt;query('SELECT description FROM location');
  
              foreach ($query-&gt;result() as $row)
              {
                  echo $row-&gt;description;
              }
  
              //echo 'Total Results: ' . $query-&gt;num_rows();
          }
  </code></pre>
  
  <p><strong>Controller.php</strong></p>
  
  <pre><code>    &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
      class Delivery_controller extends CI_Controller{
          public function __construct()
          {
              parent::__construct();
              $this-&gt;load-&gt;model('delivery_model');
  
          }
          public function index()
          {
  
              $data['title']= 'Warehouse - Delivery';
              $this-&gt;load-&gt;view('include/header',$data);
              $this-&gt;load-&gt;view('include/navbar',$data);
              $this-&gt;load-&gt;view('delivery_view', $data);
              $this-&gt;load-&gt;view('include/sidebar',$data);
              $this-&gt;load-&gt;view('include/footer',$data);
          $data['groups'] = $this-&gt;delivery_model-&gt;getAllGroups();
          }
  
  
      }
  </code></pre>
  
  <p><strong>View.php</strong></p>
  
  <pre><code>           &lt;select class="form-control"&gt;
                  &lt;?php 
                          $data = $this-&gt;delivery_model-&gt;getAllGroups();
                  foreach($description as $each)
                  { ?&gt;&lt;option value="&lt;?php echo $each['description']; ?&gt;"&gt;&lt;?php echo $each['description']; ?&gt;&lt;/option&gt;';
                  &lt;?php }
                  ?&gt;
                  &lt;/select&gt;
  </code></pre>
  
  <p>But the results appear on top of my page. It's not appearing on the dropdown list. What am I doing wrong in here? Help is pretty much appreciated. Thanks.</p>