I have a form that updates a current players information. In that form I have a drop list of teams that is populated from a mysql query. I would like the drop list to show the current selection in the database. I can't seem to get the syntax quite right because of my lack of experience.

php code to get the players information from the database
Code:
$requested_id = mysql_real_escape_string($_GET['id']);
        
        $sql = "SELECT * FROM playerstest WHERE ID = '{$requested_id}' LIMIT 1";
        
        $query = mysql_query($sql) or die("<pre>".mysql_error()."\n".$sql."</pre>");
        
        $edit_rows = mysql_fetch_assoc($query);
form code populating the list and echoing the options
PHP Code:
<?php $query_team mysql_query("SELECT `teamname` FROM `teams` ORDER BY `teamname` ASC");

                                echo 
"<select name='teamname' id='teamname'>\n";

                                while (
$data mysql_fetch_array($query_teamMYSQL_ASSOC))
                                {
                                        echo 
"<option value='{$data['teamname']}'>{$data['teamname']}</option>\n";
                                }

                                echo 
"</select>\n";
                        
?>
I think it should be something like below but can't quite get there
Code:
{

echo "<option value='{$data['teamname']}<?php if($edit_rows['teamname']=='{$data['teamname']}') echo "selected";?> '>{$data['teamname']}</option>\n";}

								echo "</select>\n";