|
Posted by Merlin on 03/29/05 12:59
Hi there,
I would like to save some db power by putting values into a file which are often
used. They basicly populate a select field.
So I placed those values into associative arrays:
$code[language] = array("1"=> "php", "2"=> "asp");
Now I would like to sort those for displaying after my preference, not by lets
say alphabet. The easiest thing I could think of, is just to move the entry:
$code[language] = array("2"=> "asp", "1"=> "php");
But this of course does not work. I would like to be able to place values later
on inbetween. So if somebody comes up with a language called ".net" :-) I would
like to place it in the middle, but I cant get it to work like that :-(
To build the select box I use following code:
<select name="education">
<option value ="0" selected>---</option>
';
################################################
# build the select field
for ($i=1; $i <= count($code[education]); $i++){
if ($education)
$isselected = ($i == $education) ? " selected" : ""; // select the
active row
else
$isselected = FALSE;
printf ("<option value =\"%s\"%s>%s</option>\n", $i, $isselected,
$code[education][$i]);
};
################################################
echo'
</select>
Has anybody an idea which could help me on that? Thank you for any help.
Merlin
[Back to original message]
|