Adding an 'All' option into a codeIgniter form_dropdown -
i have array returns locations database, trying output form drop down using following code:
<?php form_dropdown('idlocation', $querylocations, set_value('idlocation'); ?>
the $querylocations
has locationid
, locationname
. , above code works fine display locations, need add option called 'all' having idlocation
0 appear @ top of location list.
can please me this?
just prepend $querylocations
array values. here's 1 way:
form_dropdown( 'idlocation', array('0' => 'all') + $querylocations, set_value('idlocation') );
you earlier, when create $querylocations
array well.
$options[0] = 'all'; foreach ($results $r) $options[$r->idlocation] = $r->locationname;
something that...
Comments
Post a Comment