Print the visible name of a drop down menu instead of its value name

Okay so here is where my problem is occurring. I have a set of code right here:

[php]$gSelect = $_POST[‘location’];

echo"

";
echo “”;[/php]

This sets up a columned table that allows data to be displayed in a neat fashion once the users select their data restrictions. All of these restrictions are within drop down menus. $gSelect represents the drop down menu where users can select a location (Local Oh Counties, Ohio, US). Here is the drop down menu I am talking about:

[php]



Please specify a location

Fayette County (IN) Randolph County (IN) Rush County (IN) Union County (IN) Wayne County (IN) Local Indiana Counties Indiana Butler County (OH) Darke County (OH) Mercer County (OH) Preble County (OH) Local Ohio Counties Ohio United States [/php]

As you can see, the option value names (which are equal to some of my columns in my database) are different from the actual names that show up in my drop down menu (‘Rush’ versus "Rush County (IN) for instance). Echo “$gSelect”; prints the option value name for the selection. Instead, I want it to print the name that shows up in my drop down menu. Is there anyway I can fix this? Any help would be greatly appreciated. Also, I use $gSelect to set up a query to select the column for my database as well (SELECT $gSelect from table; for example), so I would like to leave $gSelect alone if possible.

Would anything like this work?

[php]echo"

Year Time $gSelect
";
echo “”;[/php]

I am just trying to figure out how to display the drop down menu name instead of the value name without changing $gSelect since I use it in queries.

Year Time $_POST[‘Location[name]’]

Check out this tutorial, it should help you.
http://amecms.com/article/Retaining-Drop-down-Selection-After-Form-Submit

overly complicated way of doing
[php]<option value =‘Fayette’ <?=(isset($_POST['location']) == 'Fayette' ? "selected='selected' : '') ?>> Fayette County (IN) [/php]
Now if you have a crap load of locations for other states, then I would highly suggest a using an array, then something like the example in the post above. I can tell you from experience that it can get tedious doing it like what I did above.

Sponsor our Newsletter | Privacy Policy | Terms of Service