select option selected according to mysql result
Posted: Sun Apr 26, 2009 6:43 pm
Hey,
Like with an input field where you can have a result from a mysql database already inputted like this:
How can I do this with a <select> drop down menu?
I have seen you have to write selected inside the <option> part of the code but how do you do this for something like this:
If the mysql result was stored as 'retro' how would I get the script to select 'retro'?
Like with an input field where you can have a result from a mysql database already inputted like this:
Code: Select all
<input type="text" value="<?php echo($line['authorwebsite']); ?>">I have seen you have to write selected inside the <option> part of the code but how do you do this for something like this:
Code: Select all
<select name="category" class="input" style="width: 172px;">
<option value="action">Action</option>
<option value="adventure">Adventure</option>
<option value="puzzle">Puzzle</option>
<option value="shooting">Shooting</option>
<option value="role playing">Role Playing</option>
<option value="sports">Sports</option>
<option value="retro">Retro</option>
<option value="fighting">Fighting</option>
<option value="racing">Racing</option>
</select>