Select Box update to MySQL
Hello, I posted this in the PHP Database Forum but didnt get much help from it. So I though maybe I could get some help from the Pros.
Hi,
Wrox has changed a bit since I was last here. Well anyway, I was wondering if any of you could help me out.
I created a select box filled with elements from a database. I can pull the data in the select drop down box. But when I post it to the next page it fails to pass the data to the next page so that I can place it into the database.
Here I am trying to pull the players name into the selectbox with the ID as the value. I can do that. Then i would like to take the matching text boxes with the stats and pass it to the next page using the post method. There is where I fail. On my Update page it successfully adds to the database but the fields are blank.
Here's a bit of the code
Can someon tell me what I am doing wrong
=========Enter Stats ================================================== ===================================
<body>
<? $SelcTeam = "Cowboys"; ?>
<form method="post" action="testupdate.php">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td bgcolor="#000000"><strong>IF THE PASSING
FIELDS ARE NOT ENOUGH TO ADD ALL PLAYERS, YOU WILL BE PROMPTED LATER TO
ADD MORE IF NECESSARY.</strong></td>
</tr>
<tr>
<td><div align="center"><strong></strong></div></td>
</tr>
<tr>
<tr bgcolor="#FF0000">
<th colspan="12" nowrap><div align="center">
<p>PASSING STATS</p>
</div></th>
</tr>
<tr bgcolor="#0000FF">
<th nowrap>Name</th>
<th nowrap>Ratings</th>
<th nowrap>Yards</th>
<th nowrap>TD</th>
<th nowrap>Int</th>
<th nowrap>Comp</th>
<th nowrap>Att</th>
<th nowrap>Comp%</th>
<th nowrap>Avg</th>
<th nowrap>Yds/<br>
Game</th>
<th nowrap>Sack</th>
<th nowrap>Long</th>
</tr>
<tr align="center" valign="middle" bgcolor="#CCCCCC">
<td nowrap>
<?
//change the following variables with the appropriate
$host = "localhost";
$dbname = "*********";
$dbpass = "*********";
$connection = mysql_connect("$host","$dbname","$dbpass");
$db = mysql_select_db("$dbname",$connection);
echo"<select name=\"Passing\"><option value=\"RosterPlayer\">Select Player</OPTION>"; //start the select box
$results= mysql_query("SELECT * from Players where Team='".$SelcTeam."'");
$id = PLAYERID;
$idname = NAME;
$idPosition = POS;
$idTeam = TEAM;
echo mysql_error();
if (mysql_Numrows($results)>0) //if there are records in the fields
{
$numrows=mysql_NumRows($results); //count them
$x=0;
while ($x<$numrows){ //loop through the records
$theId=mysql_result($results,$x,$id); //place each record in the variable everytime we loop
$theName=mysql_result($results,$x,$idname);
$thePos=mysql_result($results,$x,$idPosition);
$theTeam=mysql_result($results,$x,$idTeam);
echo "<option value=\"$theId\">".$theName." (".$theTeam." ".$thePos.")</option>\n"; //and place it in the select
$x++;
}
}
echo "</select>"; //close the select
?>
</td>
<td nowrap><input name="PassRatings" type="text" id="PassRatings" size="5" maxlength="85"></td>
<td nowrap><input name="PassYds" type="text" id="PassYds" size="5" maxlength="85"></td>
<td nowrap><input name="PassTD" type="text" id="PassTD" size="5" maxlength="85"></td>
<td nowrap><input name="PassINT" type="text" id="PassINT" size="5" maxlength="85"></td>
<td nowrap><input name="PassComp" type="text" id="PassComp" size="5" maxlength="85"></td>
<td nowrap><input name="PassATT" type="text" id="PassATT" size="5" maxlength="85"></td>
<td nowrap><input name="PassCompPCT" type="text" id="PassCompPCT" size="5" maxlength="85"></td>
<td nowrap><input name="PassAVG" type="text" id="PassAVG" size="5" maxlength="85"></td>
<td nowrap><input name="PassYdsGm" type="text" id="PassYdsGm" size="5" maxlength="85"></td>
<td nowrap><input name="PassSack" type="text" id="PassSack" size="5" maxlength="85"></td>
<td nowrap><input name="PassLong" type="text" id="PassLong" size="5" maxlength="85"></td>
</tr>
<tr align="center" valign="middle">
<td nowrap>
================================================== ================================================== ============
========Update Stats Page ================================================== =====================================
<body>
<?
//change the following variables with the appropriate
$host = "localhost";
$dbname = "*********";
$dbpass = "*********";
$connection = mysql_connect("$host","$dbname","$dbpass");
$db = mysql_select_db("$dbname",$connection);
mysql_query ("INSERT INTO `verifystats` (PlayerID,Team,GameNumber,Name,Rating,PassYds,Pass Tds,PassInts,PassComp,PassAtt,PassPercent,PassAvg, PassYdsGm,PassSack,PassLong)where `PlayerID`='".$Passing2."'",$connection)
VALUES ('Player',' Team', '0',' Name', $PassRatings, $PassYds, $PassTD, $PassINT, $PassComp, $PassATT, $PassCompPCT, $PassAVG, $PassYdsGm, $PassSack, $PassLong);
//$result=mysql_query
//echo mysql_error()
?>
</body>
|