Hello guys first of all thanks for taking the time to read.
Right on to the problem…...
I am trying to create a drop-down from a mysql query and fill the array in the controller by using a for each loop, then load the view and just fill the drop-down using a variable so to keep all the logic in the controller.
Heres what I have so far…
The Controller:
function new_raw_materials()
{
$this->load->model(');
$suppliers = $this->mdl_supplier->get();
//Generate Supplier Name List
foreach($suppliers as $row)
{
$data['options'] = array( $row->supplier_id => $row->supplier_name);
}
//Dynamicaly Generate the Base URL so we know the location of the css file.
$baseURL = $this->config->item('base_url');
$data["baseURL"] = $baseURL;
$this->load->view("admin/new_raw_materials",$data);
}
The View:
<tr>
<td>Raw Materials Supplier Name:</td> <td><?=form_dropdown('supplier_id',$options, '1'); ?></td>
</tr>
I am pretty sure the problem lies with the way I am filling the array but I am not sure on how to create dynamic expanding array without putting the logic inside the array which I don’t think you can do.
Thanks for your time
Regards
