Drop Down Lists
Posted: Tue Feb 15, 2011 12:27 pm
I found a script which creates a nice drop down list from a mysql database (a list of football teams). What I want to do is select a team by name, then insert the team_id into a "reference" field in another table.
Once a team is selected, how do I return just the team_id?
----drop down list code----
----end code----
I want to create a variable ($hometeam) that is just the team_id number so I can pass it to my insert.php file.
Thanks for helping a newbie!!
Once a team is selected, how do I return just the team_id?
----drop down list code----
Code: Select all
<?php
include("opendatabase.php");
$querya="SELECT team_id,team_name FROM teams";
$resulta = mysql_query ($querya);
echo "<select team_name=option value=''></option>";
while($hometeam=mysql_fetch_array($resulta))
{
echo "<option value=$hometeam[team_id]>$hometeam[team_name]</option>";
}
echo "</select>";
?>
I want to create a variable ($hometeam) that is just the team_id number so I can pass it to my insert.php file.
Thanks for helping a newbie!!