I have set up a page to add data to a table, but am having a couple problems. Please refer to the following webpage to see:
http://www.refphotos.com/show_addgame_DD.php
Problem #1:
The dropdown menus under "Home Team" and "Visiting Team" are supposed to draw the names of teams from a field "team" in the table "teams". As you can see, this is working fine for the first one, but it only displays a blank menu for the second one. These need to both display the exact same list. The code for this page is below.
Problem #2:
When the "Add Game to Schedule" button is pressed, a page "do_addgame.php" is executed which adds the data to the table "schedule". It is currently working properly EXCEPT that it does not add the selection from either of the above mentioned dropdown menus. What do I need to add/change for code to make it work??? The code for the do_addgame.php page is in the 2nd post in this thread.
Can someone please tell me what is wrong with the code? I'm at a loss.
Thank you very much for any help!
Landis
// CODE FOR FORM PAGE WITH DROP DOWN MENUS, PROBLEM #1
<?
//start a session
session_start();
//validate user to see if they are allowed to be here
if ($_SESSION[valid] != "yes") {
header("Location: referee_menu.php");
exit;
}
$db_name ="refphoto_testdb";
$table_name ="teams";
$connection = @mysql_connect("localhost","refphoto","08291983") or die(mysql_error());
$db = @mysql_select_db($db_name,$connection) or die(mysql_error());
$sql = "SELECT id, team FROM $table_name ORDER BY team";
$result = @mysql_query($sql,$connection) or die(mysql_error());
?>
<HTML>
<HEAD>
<TITLE>Referee Management System:Add a Game</TITLE>
</HEAD>
<BODY>
<h1><font face="Verdana, Arial, Helvetica, sans-serif">Referee Management System</font></h1>
<h2><font face="Verdana, Arial, Helvetica, sans-serif"><em>Add a Game</em></font></h2>
<FORM METHOD="post" ACTION="do_addgame.php">
<table cellspacing=2 cellpadding=2>
<tr>
<th bgcolor="#CCCCCC"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">GAME
INFORMATION</font></th>
<th bgcolor="#999999"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">OFFICIAL
ASSIGNMENTS</font></th>
</tr>
<tr>
<tr>
<td valign=top bgcolor="#CCCCCC">
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Date
(enter in format YYYY/MM/DD):</strong><br>
<input type="text" name="date" size=35 maxlength=75</p>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Season
Code, Use Following Code:<br>
</strong>Winter Season - YYYY-01-01<br>
Spring Season - YYYY-02-01<br>
Summer Season - YYYY-03-01<br>
Fall Season - YYYY-04-01<br>
<input type="text" name="gamecode" size=20 maxlength=75</p>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Start
Time (enter in format hh:mm):</strong><br>
<input type="text" name="time" size=35 maxlength=75</p>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Game
Location:</strong><br>
<input type="text" name="location" size=35 maxlength=100</p>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Home
Team:</strong><br>
<SELECT name="home" id="home">
<?
// put data into drop-down list box
while ($row = mysql_fetch_array($result)) {
$home = $row["team"];
echo "<OPTION value=\"$home\">$home</OPTION>";
}
?>
</SELECT>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Visiting
Team:</strong><br>
<SELECT name="visitor" id="visitor">
<?
// put data into drop-down list box
while ($row = mysql_fetch_array($result)) {
$visitor = $row["team"];
echo "<OPTION value=\"$visitor\">$visitor</OPTION>";
}
?>
</SELECT>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>League:</strong><br>
<select name="league" id="league">
<option>High School</option>
<option>Middle School</option>
<option>IPSL</option>
<option>ILLOWA</option>
<option>Other</option>
<option selected> </option>
</select>
</font></td>
<td valign=top bgcolor="#999999">
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Referee:</strong><br>
<input type="text" name="referee" size=35 maxlength=75</p>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Assistant
Referee 1:</strong><br>
<input type="text" name="ar1" size=35 maxlength=75</p>
</font>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Assistant
Referee 2:</strong><br>
<input type="text" name="ar2" size=35 maxlength=75</p>
</font></td>
</tr>
<tr>
<td align=center colspan=2> <font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="Add Game to Schedule">
</font><font face="Verdana, Arial, Helvetica, sans-serif">
<p><font size="2"><a href="referee_menu.php">Return to Main Menu</a></font></p>
</font></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>