Hello, might be a fairly simple (hopefully) solution but...
I've been looking for answers to this problem but I haven't been able to come up with something that works in my situation.
Basically what I want to do is have 4 pages linked in this order and function:
Page 1: Select two teams.
Page 2: Call up those two teams and their season stats. Input the desired values and go to;
Page 3: Call up the two teams' player rosters. Input the desired values and go to;
Page 4: Call up the two teams' goalie rosters. Input the desired values.
Keep in mind that it is updating multiple records each time (at least 2, and in the case of the player rosters, about 40). I can get them all to work independently, but I do not know how to link them all together.
Basically on page one you use an option list and pick two teams and store them as $Team1 and $Team2 to be used in the second form (<form method="GET" action="statsthrough1.php">)
The second page can get the two values just fine (I.e. Toronto and Boston) and display the relevant information.
Part of Page 2 (statsthrough1.php):
mysql_select_db ("xshocke_players",$db);
$query="SELECT * FROM teams WHERE Team='$Team1' or Team='$Team2' ORDER BY Team";
$result=mysql_query($query);
echo "<center><h1> Team Stats Submission </h1></center>";
if (mysql_num_rows($result) !=0) {
echo "<table width=90% align=center>\n";
echo "<form method=POST>\n";
echo "<tr><td>Team</td><td>W</td><td>L</td><td>T</td><td>OTL</td><td>GF</td><td>GA</td><td>Shots</td><td>Hits</td><td>PIM</td><td>PPG</td><td>PPA</td><td>PK</td><td>PKT</td></tr>\n";
while ($r = mysql_fetch_array($result)) {
$id = $r["id"];
$Team = $r["Team"];
$GP = $r["GP"];
$Wins = $r["Wins"];
$Losses = $r["Losses"];
$Ties = $r["Ties"];
$OTL = $r["OTL"];
$GF = $r["GF"];
$GA = $r["GA"];
$Shots = $r["Shots"];
$Hits = $r["Hits"];
$PIM = $r["PIM"];
$PPScored = $r["PPScored"];
$PPAttempts = $r["PPAttempts"];
$PKKilled = $r["PKKilled"];
$PKTotal = $r["PKTotal"];
echo "<input type=hidden name=yapp[$id] value='$id'>\n";
echo "<tr><td><input type=text readonly name=yapp[$id][Team] value='$Team' size=20></td>\n";
echo "<input type=hidden name=yapp[$id][GP] value='0' size=2>\n";
echo "<td><input type=text name=yapp[$id][Wins] value='0' size=2></td>\n";
echo "<td><input type=text name=yapp[$id][Losses] value='0' size=2></td>\n";
echo "<td><input type=text name=yapp[$id][Ties] value='0' size=2></td>\n";
echo "<td><input type=text name=yapp[$id][OTL] value='0' size=2></td>\n";
echo "<td><input type=text name=yapp[$id][GF] value='0' size=3></td>\n";
echo "<td><input type=text name=yapp[$id][GA] value='0' size=3></td>\n";
echo "<td><input type=text name=yapp[$id][Shots] value='0' size=5></td>\n";
echo "<td><input type=text name=yapp[$id][Hits] value='0' size=5></td>\n";
echo "<td><input type=text name=yapp[$id][PIM] value='0' size=5></td>\n";
echo "<td><input type=text name=yapp[$id][PPScored] value='0' size=3></td>\n";
echo "<td><input type=text name=yapp[$id][PPAttempts] value='0' size=3></td>\n";
echo "<td><input type=text name=yapp[$id][PKKilled] value='0' size=3></td>\n";
echo "<td><input type=text name=yapp[$id][PKTotal] value='0' size=3></td>\n";
}
echo "<tr><td align=center colspan=15><input type=submit name=submit value=submit></td></tr>\n";
?>
<?php
echo "</form>";
echo "</table>";
} else {
echo "Couldn't fetch info from the db...";
}
} else {
$db=mysql_connect ("localhost", "xshocke_admin", "secret") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("xshocke_players",$db);
while (list ($key) = each ($HTTP_POST_VARS[yapp])) {
$query="UPDATE teams SET ";
foreach ($HTTP_POST_VARS[yapp][$key] as $key1 => $value1) {
if (!empty($value1)) {
//see if the $key1 variable is the correct column then
//change the code to add the current value and the input value
if (($key1=="GP")||($key1=="Wins")||($key1=="Losses")||($key1=="Ties")||($key1=="OTL")||($key1=="GF")||($key1=="GA")||($key1=="Shots")||($key1=="Hits")||($key1=="PIM")||($key1=="PPScored")||($key1=="PPAttempts")||($key1=="PKKilled")||($key1=="PKTotal")){
$query.="$key1=$key1+$value1 ,";
$query.="Points = (Wins * 2) + OTL + Ties, ";
$query.="ShootingPct = round(GF / Shots,3), ";
$query.="GAA = round(GA / GP,2), ";
$query.="GFA = round(GF / GP,2), ";
$query.="ShotsAvg = round(Shots / GP,2), ";
$query.="HitsAvg = round(Hits / GP,2), ";
$query.="PIMAvg = round(PIM / GP,2), ";
}
else{
$query.="$key1='$value1', ";
}
}
}
$query=substr($query, 0,-2);
$query.=" WHERE id=$key";
echo "$query <br>";
$result=mysql_query($query) or die (mysql_error());
}
The other pages look much like page 2. And sorry about the big code blocks.
How can I get this to work together? Please help oh wise ones. Just doing a basic action="through3.php" doesn't work (it seems to skip ahead to the next page instead of going through the rest of the one it's already on).