I am trying to pre-select an element in an html <select> tag based on a PHP variable.
The PHP variable stores the name of the user's city (which exactly matches its corresponding element in the drop-down box), so I want that city to be selected when the page is loaded.
Here is the code that I have (obviously it does not work):
<select name="City" value="<?php echo $city ?>">
*a bunch of cities listed*
</select>
The PHP variable stores the name of the user's city (which exactly matches its corresponding element in the drop-down box), so I want that city to be selected when the page is loaded.
Here is the code that I have (obviously it does not work):
<select name="City" value="<?php echo $city ?>">
*a bunch of cities listed*
</select>