[eluser]Tenter[/eluser]
Hello,
I have a problem with my code.. i cant figure out how to get it work.. The problem is that i have this array wich i get from my model:
Code:
public function get_all_dansetyper()
{
$sql = "SELECT
id,
danseart
FROM
dansearter
ORDER BY
id";
$result = $this->db->query($sql);
return $result->result();
}
Afterwards i use this get funktion in my controller:
Code:
public function index()
{
$data['dansetyper'] = $this->danse_model->get_all_dansetyper();
$this->load->view('snippets/header');
$this->load->view('tilmaelding', $data);
$this->load->view('snippets/footer');
}
And this variable "dansetyper" ill send to my view file with the array in, this array is an object and i cant just put it into my:
Code:
<php
$options = "";
$options .= "array(";
foreach($dansetyper as $dansetype):
$options .= "'" . $dansetype->id . "' => '" . $dansetype->danseart . "', ";
endforeach;
$options .= ");";
die(var_dump($options));
?>
<?php echo form_dropdown('dansetype', $options, 'large');?>
the $options now contain a string with
Code:
string 'array('1' => 'Folkedans', '2' => 'Selskabsdans', '3' => 'Linedans', );' (length=70)
My question is, How do i fill my form_dropdown with information from my sql array??