[eluser]SPeed_FANat1c[/eluser]
[quote author="Bigil MM" date="1303924265"][quote author="SPeed_FANat1c" date="1303915482"]
Code:
function create_dropwdown()
{
$query = 'select * from table';
$html = '<select name="mydropdown">'
foreach($query->result() as $row )
{
if($row->parent == 0)
$html .= '<option class = "category" value="'.$row->id.'">'.$row->heading.'</option>';
else $html .= '<option class = "not_category" value="'.$row->id.'">'.$row->heading.'</option>';
}
$html .= '</select>';
return $html;
}
Something like this. I havent tested it. You can now use css to change color for option where class = "category"[/quote]
can u split this into
model view and controller?
i didn't understand which is the controller portion, model and view[/quote]
This function probalby would fit in model.
So now the controller index function:
Code:
function index()
{
$this->load->model('dowpdown_model');
$data['dropdown'] = $this->dowpdown_model->create_dropwdown();
$this->load->view('your_page_view',$data);
}
And view:
Code:
...some html...
<?php echo $dropdown ?>
...some ohter html...