Forum Moderators: coopster
I need to achieve the following:
Have a column in my database called Items and another called Option.
I need to print a select form menu to the page, using the two fields above, the Option for the name and the Items for the menu items, but these are to be stored in an array, split by a ,
There will be varying amounts of options in the Option column for different products, so it needs to be able to be dynamic and not fixed at a certain amount off variables.
So, in short, I need to get the following:
Option ¦ Colour
Items ¦ Red,Green,Blue,Orange,Violet
to print out like so:
<select name="Colour">
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
<option value="Orange">Orange</option>
<option value="Violet">Violet</option>
</select>
I really help someone can help me out here, this is something that has stumped me! :(
I have looked at the explode function, but couldn't get past it printing out the list of values.
Cheers,
wruk999
$itemlist = explode [ca.php.net](",",$row[1]);
echo "<select name=\"Colour\">\n";
foreach ($itemlist as $selectitem) {
echo "<option value=\"$selectitem\">$selectitem</option>\n";
}
echo "</select>\n";
should work