function pullTeamsSelect($area)
{
    global $db;
    try {
        $teamsQuery = $db->prepare("SELECT * FROM teams WHERE area=:area ORDER BY name");
        $teamsQuery->execute(array(':area' => $area));
    } catch (PDOException $e) {
        exit("error in query");
    }
    while ($cur = $teamsQuery->fetch(PDO::FETCH_ASSOC)) {
        echo "<tr><td><input type='text' name='" . $cur['ID'] . "name' value=\"" . $cur['name'] . "\" /></td>";
        echo "<td><select name='" . $cur['ID'] . "lead'>";
        teamLeaderSelect($area, $cur['lead']);
        echo "</select></td></tr>";
    }
}
<h1>Training Team Leaders</h1>
<h4>INSTRUCTIONS: After editing a team name or changing a team leader <br/>click "Submit Changes" BEFORE doing anything else or your changes will not be saved.</h4>
</div>
<form name='addTeam' method='post'>
	<div class='center'>
    <input type='button' name='newTeam' value="Insert New Team" onclick='$("#createTeamDialog").dialog("open")' />
	
    <input type='submit' class='button' name='submit' value="Submit Changes" /> 
     
	</div>
	<div name='results' id='results' class='center'>
	
	</div>
	<br/>
</form>

<div id="createTeamDialog" title = "Create New Team">
	<form id = "createTeam" name = "createTeam" method = "post" action = "insertTeam.php">
		<label for = "createTeamName">Team Name: </label>
		<input type = "text" id = "createTeamName" name = "createTeamName">
		
		<label for = "createTeamLeader">Team Leader: </lable>
		<select name = "createTeamLeader"><?php 
teamLeaderSelect($area, '');
?>
</select>
	</form>
</div>

<?php 
require '../includes/includeAtEnd.php';