[eluser]tonanbarbarian[/eluser]
yeah i admit that i would prefer if the structure of the options in form_dropdown worked a bit differently
but to get it to work try something like this
Code:
$options = array();
$this->db->select('xxx AS value, yyy AS text');
$this->db->from('zzz');
....
// or use
// $query = $this->db->query('SELECT xxx AS value, yyy AS text FROM zzz');
$query = $this->db->get();
if ($query->num_rows()) {
foreach ($query->result_array() as $row) {
$options[$row['value']] = $row['text'];
}
}
$query->free_result();
unset($query);
The query will return results like
Code:
array(
array(
'value'=>1,
'text'=>Hello
),
array(
'value'=>2,
'text'=>Something
),
array(
'value'=>6,
'text'=>Different
),
array(
'value'=>96,
'text'=>What
)
);
and then the processing of the results will return something like
Code:
array(
1=>Hello,
2=>Something,
6=>Different,
96=>What
);
This resulting array is what form_dropdown needs, and if you are hard coding the values this is the easiest to create
However I prefer the first format for the options because it is much easier to retrieve from a query and does not require any processing before being passed to the function.
p.s.
while
Code:
$query->free_result();
unset($query);
is not strictly necessary, it is a good idea to clean up after yourself