[eluser]ciPhil[/eluser]
Hi, I am still trying to learn and am stuck with this problem.
I can solve it by running all the code from within the controller but I need to get the idea of passing the data around to use mvc.
I think my problem is in the use of arrays in passing the data, the code is below, or then again maybe its some other misunderstanding, a lot of this code is from David Upton,s book.
Can anyone help with a simple explanation of my errors,
Thanks
Phil
<?php
class Width extends Controller {
function index()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('table');
$this->load->database();
$this->output->enable_profiler(TRUE);
$this->load->model('get_width');
$data = $this->get_width->get_all();
$this->load->view('drop_form_view',$data);
}
}
?>
MODEL
<?php
class Get_width extends Model {
function Get_width()
{
parent::Model();
}
function get_all()
{
$width_array = array();
$this->db->select('id, width');
$query = $this->db->get('tyre_width');
if ($query->num_rows() >0)
{
foreach ($query->result() as $row)
{
$width_array[$row->id] = $row->width;
}
}
return $width_array;
}
}
?>
VIEW
<head>
<body>
<?php
echo form_dropdown('width', $data, '1'); ?>
</body>
</head>