Hi,
I am trying to set the selected option in a dynamically generated drop box using a variable passed from another page. Here's my code:
$query_venue = "select venue_name from venues";
$query_result = mysql_db_query($db,$query_venue);
for ($i=1; $i<=mysql_num_rows($query_result); $i++) {
$object_venue = mysql_fetch_object($query_result);
echo "<option value=\"$gig_venue\" selected>$gig_venue</option>\n";
echo "<option value=\"".$object_venue->venue_name."\">".$object_venue->venue_name."</option>\n";
}
echo "</select>\n";
The variable $gig_venue is on another table, but matches one entry in the $venue_name array.
Generating the list is okay, but once I try to start with an option selected I get $gig_venue selected, but then it also appears in the list once for every entry in the $venue_name array.
Am I asking the impossible?
Cheers,
Dan
I am trying to set the selected option in a dynamically generated drop box using a variable passed from another page. Here's my code:
$query_venue = "select venue_name from venues";
$query_result = mysql_db_query($db,$query_venue);
for ($i=1; $i<=mysql_num_rows($query_result); $i++) {
$object_venue = mysql_fetch_object($query_result);
echo "<option value=\"$gig_venue\" selected>$gig_venue</option>\n";
echo "<option value=\"".$object_venue->venue_name."\">".$object_venue->venue_name."</option>\n";
}
echo "</select>\n";
The variable $gig_venue is on another table, but matches one entry in the $venue_name array.
Generating the list is okay, but once I try to start with an option selected I get $gig_venue selected, but then it also appears in the list once for every entry in the $venue_name array.
Am I asking the impossible?
Cheers,
Dan