I need help with my page. I am taking two variables from another page as Posts. The two variables are numbers that I will later need to change to names they are assigned to in my table. I then start to build an html table and form.
My SQL table has the first post variable (AwayTeam or HomeTeam) associated with the second post variable (week). The if statements determine if the first post variable is an away or home team as I'd then post the third column (SQL table) as the opponent.
I have a simple function that will convert the number IDs from one table to the actual team names. I return that team name value to the main script to echo to the page.
The script will only see the first away team name. Any assistance?
<?
$teamlist=$_POST['teamlist'];
$seriesweek=$_POST['seriesweek'];
//include file
$con = mysql_connect($serverhost,$account,$key);
if (!$con)
{ die('Could not connect: ' . mysql_error());
}
mysql_select_db("rontoec_teams", $con);
echo "<form action='testworks.php' method='post'>";
echo "<table>";
echo "<tr>";
echo "<td>Series</td>";
echo "<td>Home Team</td>";
echo "<td>Away Team</td>";
echo "<td></td>";
echo "</tr><tr>";
echo "<td>";
$request = mysql_query("SELECT * FROM schedule WHERE Week = $seriesweek");
while ($array = mysql_fetch_array($request))
{
if ($array[AwayTeam] == $teamlist)
{
$opponent=$array['HomeTeam'];
echo $selectedaway=teamselect($teamlist) . " at " . $selectedhome=teamselect($opponent);
echo "</td>";
echo "<td><input name='updatewinsaway' type='text' value=" . $array[AwayWins] . " /></td>";
echo "<td><input name='updatewinshome' type='text' value=" . $array[HomeWins] . " /></td>";
}
if ($array[HomeTeam] == $teamlist)
{
$opponent=$array['AwayTeam'];
echo $selectedaway=teamselect($opponent) . " at " . $selectedhome=teamselect($teamlist);
echo "</td>";
echo "<td><input name='updatewinsaway' type='text' value=" . $array[AwayWins] . " /></td>";
echo "<td><input name='updatewinshome' type='text' value=" . $array[HomeWins] . " /></td>";
}
}
echo "<td><input type='submit'></td></tr></table>";
echo "</form>";
function teamselect($team) {
$yourteam = mysql_query("SELECT * FROM teams");
while($row = mysql_fetch_array($yourteam))
{
if ($team == $row['xid'])
{
$selected = $row['name'];
}
return $selected;
}
}
?>