|
Make drop down menu list automaticly selected in php?
I’m having a story script where author has to select the character in the list. How do I make the list selected on a certain character even before the author does anything?
Here’s part of the script:
$result = mysql_query("SELECT gid, genre FROM ".$tableprefix."fanfiction_genres");
$numgenres = mysql_num_rows($result);
$output .= "<INPUT type=\"hidden\" name=\"numgenres\" value=\"$numgenres\">";
if($numgenres != "0")
{
if($gid == "")
$output .= "<font style=\"color:red\">";
$output .= ""._GENRES.":";
if($gid == "")
$output .= "</font>";
$output .= "</td><td>";
$output .= "<select name=\"gid[]\" size=\"5\" multiple>";
while ($genreresults = mysql_fetch_array($result))
{
$output .= "<option value=\"$genreresults[genre]\"";
if($gid != "")
{
if(in_array($genreresults[genre], $gid))
$output .= " selected";
}
$output .= ">$genreresults[genre]</option>";
}
}
$output .= "
</td><td>"._GENREINFO."
Do you need the whole script? I know nothing about php. I tried to add the <option selected>character’s name</option> but it didn’t really work because I don’t know where to add it nor is it the right code.
|