Drop Down Menu
Moderator: General Moderators
-
Straterra
- Forum Regular
- Posts: 527
- Joined: Mon Nov 24, 2003 8:46 am
- Location: Indianapolis, Indiana
- Contact:
Drop Down Menu
I have a a website with a bio section. There is a drop down menu with 50 or so options...When the person selects one, their desicion is stored in a database..I can withdraw the information correctly and everything, but when they go back to edit their bio, how can I make it so that whatever they HAD selected is the default thing? I have done with with if then statements, but there are too many possibilites to have if/then/else and case/switch.....Is there another way to do this?
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Have you tried this code snippet: PHP/HTML: Print <select><options></select>? I hope it helps.
well, this is how i do it:
if "value" is diffrenet then you have to make another array with values..thats the down side i guess.
Code: Select all
<?php
$options[]= "option1";
//and so on
$options[] = "option 50";
$user_selected = $_POST['select_box_name'];
for($x = 0; $x<=count($options); $x++)
{
$selected = "";
if($option[$x] == $user_selected)
{
$selected = "selected";
}
echo "<option value="$option[$x]"$selected>$option[$x]</option>\n";
}
?>