Du borde inte kalla din modell från din synvinkel. Försök istället att kalla dig modell och ställa in $data['groups']
innan du laddar dina vyer.
Eka inte heller radresultaten i din modell om du inte vill att den ska visas på din sida.
Controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Delivery_controller extends CI_Controller{
public function __construct()
{
parent::__construct();
$this->load->model('delivery_model');
}
public function index()
{
$data['title']= 'Warehouse - Delivery';
$data['groups'] = $this->delivery_model->getAllGroups();
$this->load->view('include/header',$data);
$this->load->view('include/navbar',$data);
$this->load->view('delivery_view', $data);
$this->load->view('include/sidebar',$data);
$this->load->view('include/footer',$data);
}
}
Modell:
public function __construct()
{
parent::__construct();
}
function getAllGroups()
{
/*
$query = $this->db->get('location');
foreach ($query->result() as $row)
{
echo $row->description;
}*/
$query = $this->db->query('SELECT description FROM location');
return $query->result();
//echo 'Total Results: ' . $query->num_rows();
}
Visa:
<select class="form-control">
<?php
foreach($groups as $row)
{
echo '<option value="'.$row->description.'">'.$row->description.'</option>';
}
?>
</select>