View Full Version : option value selected problem

09-05-2009, 12:28 PM
I'm returning form inputs to a form (from mysql) so that the inputs can be edited. It's going OK but I've got this issue.
I want an input, chosen from a dropdown and saved in mysql, to be returned to the top of the dropdown list - a reminder to the user that this is what they chose before. Now I know the string is being taken from the database because I've echoed it. But I cannot get it to appear in the dropdown list when the form boots in from the login. I'm sure it's a syntax problem because it doesn't look right.

<option value selected = <?php "$main genre">echo $main genre?> </option> (PS this returns a parse error notice)

In variations of the above which do not receive a notice I've managed to get the top of the list to turn blue (ie selected) but the string does not appear with it. Could someone tell me what the correct syntax is for the line above ?

09-06-2009, 06:22 PM
For those who might view this (and you may have known the solution) this works:
echo "<option value=$main_genre selected>'$main_genre'</option>"