Something is weird. My update statement works fine in FireFox, but the client is using IE8 and the UPDATE fails. It also fails in Chrome. I am suspecting that something is wrong in my FOREACH statement--but I can't spot it. Any ideas?
//---| UPDATE
if($_POST['submit']=="Save")
{
foreach($_POST['teamGroup_ud'] as $coachID => $value)
{
$teamGroup = (protect($_POST['teamGroup_ud'][$coachID]));
$teamPool = (protect($_POST['teamPool_ud'][$coachID])) ;
$teamFlight = (protect($_POST['teamFlight_ud'][$coachID])) ;
$regionID = (protect($_POST['regionID_ud'][$coachID])) ;
$query = "UPDATE team_info SET
regionID ='$regionID' ,
teamGroup ='$teamGroup' ,
teamPool ='$teamPool' ,
teamFlight ='$teamFlight'
WHERE coachID = '$coachID' LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
}
}
Here's the entire code, including the FOREACH statement just in case you have any other thoughts.
<?php
session_start();
require("../validateAdmin.php");
require("../functions/checkEntries.php");
include_once "../DBconMOD.php";
include_once "../style_sheet.php";
//---| UPDATE
if($_POST['submit']=="Save")
{
foreach($_POST['teamGroup_ud'] as $coachID => $value)
{
$teamGroup = (protect($_POST['teamGroup_ud'][$coachID]));
$teamPool = (protect($_POST['teamPool_ud'][$coachID])) ;
$teamFlight = (protect($_POST['teamFlight_ud'][$coachID])) ;
$regionID = (protect($_POST['regionID_ud'][$coachID])) ;
$query = "UPDATE team_info SET
regionID ='$regionID' ,
teamGroup ='$teamGroup' ,
teamPool ='$teamPool' ,
teamFlight ='$teamFlight'
WHERE coachID = '$coachID' LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php echo "<title>Control Panel </title>";?>
<link rel="stylesheet" type="text/css" href="../../templates/master_style_sheet.css" />
<link rel="stylesheet" type="text/css" href="../templates/master_style_sheet.css">
<link rel="stylesheet" type="text/css" href="../style_sheets/tournament_style_sheet.css">
<style type="text/css">
.table_small_type {
border: 1px solid #008000;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: xx-small;
text-decoration: underline;
}
.coach_left_just {
border: 1px solid #008000;
text-align: left;
font-family: Arial, Helvetica, sans-serif;
font-size: small;
}
</style>
</head>
<body> <span class="red_italic_text_medium">
<img src="../artwork/CupLogo.png" width="265" height="94">Assign Groups and
Pools<hr></span>
<?php
include('../navigation/admin_menu.htm');
?>
<!-- DROP DOWN MENU to choose division -->
<form method="post" name="divSearch"><label class="small_type"><strong>Division:</strong></label>
<select name="showWhat" onchange="javascript:document.divSearch.submit()">
<option value="View All"> Choose </option>
<option value="U10 Boys"> U10 Boys</option>
<option value="U12 Boys">U12 Boys</option>
<option value="U14 Boys">U14 Boys</option>
<option value="U16 Boys">U16 Boys</option>
<option value="U19 Boys">U19 Boys</option>
<option value="U10 Girls">U10 Girls</option>
<option value="U12 Girls">U12 Girls</option>
<option value="U14 Girls">U14 Girls</option>
<option value="U16 Girls">U16 Girls</option>
<option value="U19 Girls">U19 Girls</option>
</select>
<input name="Submit1" type="submit" value="See Division" />
<span class="small_type">PRINT </span><span class="cell_borderLeft">
<a target="_self" href="../pools/display_pools.php">Pools</a> </span><br>
</form>
<p><span class="small_type">Use this page to assign the Group and Pool
information to each team. <strong>ONLY </strong>teams who have been approved
by TD will appear. If Team Type, Team Rating and or Team Age does not
appear--it means that the TD approved the tournament, but the coach did not
fill those fields in on their applications. Note: Be aware that this version does not take
into account Coed Teams. We may have to manually modify those very few teams
to to fit the programs needs. </span></p>
<form method="post">
<table style="width: 100%" class="cell_border">
<tr class="background_color">
<td class="cell_border" width="5%"><strong>Group</strong></td>
<td class="cell_border" width="5%"><strong>Team #</strong></td>
<td class="cell_border" width="5%"><strong>Flight</strong></td>
<td class="cell_border" width="5%"><strong>Region</strong></td>
<td class="cell_border" width="15%"><strong>Reg Name</strong></td>
<td class="cell_border" width="5%"><strong>Reg ID</strong></td>
<td class="cell_border" width="20%"><strong>Coach</strong></td>
<td class="cell_border" width="25%"><strong>Team Type</strong></td>
<td class="cell_border" width="5%"><strong>Team Rate</strong></td>
<td class="cell_border" width="5%"><strong>Team ID#</strong></td>
</tr>
<?php
//---|Assign Flight colors
$red= "Red";
$blue = "Blue";
$green = "Green";
$orange= "Orange";
//--| load records from team_info
if ($_POST['showWhat'])
{
$showWhat = $_POST['showWhat'];
$_SESSION['old'] = $showWhat;
}
else
{
$showWhat = $_SESSION['old'];
}
print "<span class=\"background_color\">Displaying<strong> " . $showWhat . "</strong></span><br/>";
$result=mysql_query("SELECT *
FROM team_info
WHERE whatDiv= '".$showWhat."' && packetApproved = 1
ORDER BY teamRating + 0 DESC");
//ORDER BY teamFlight, teamGroup, teamPool ASC");
while ($contact = mysql_fetch_array($result))
{
?>
<tr>
<td class="cell_border">
<select name="
<?php echo '
teamGroup_ud[' . $contact['coachID'] . ']'; ?> ">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value ="<?php echo $contact['teamGroup'];?>"
selected><?php echo $contact['teamGroup'];?></option>
</select>
<td class="cell_border">
<select name="
<?php echo '
teamPool_ud[' . $contact['coachID'] . ']'; ?> ">
<option value=""></option>
<option value="A">A</option>
<option value="AA">AA</option>
<option value="B">B</option>
<option value="BB">BB</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
<option value="F">F</option>
<option value="G">G</option>
<option value="H">H</option>
<option value="I">I</option>
<option value="J">J</option>
<option value="K">K</option>
<option value="L">L</option>
<option value="M">M</option>
<option value="N">N</option>
<option value="O">O</option>
<option value="P">P</option>
<option value="Q">Q</option>
<option value="R">R</option>
<option value="S">S</option>
<option value="T">T</option>
<option value="U">U</option>
<option value="V">V</option>
<option value="W">W</option>
<option value="X">X</option>
<option value="Y">Y</option>
<option value="Z">Z</option>
<option value ="<?php echo (htmlentities($contact['teamPool']));?>"
selected><?php echo (htmlentities($contact['teamPool']));?></option>
</select>
<!-- Team Flight Color -->
<td class="cell_border">
<select name="
<?php echo '
teamFlight_ud[' . $contact['coachID'] . ']'; ?> ">
<option value=""></option>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
<option value="Orange">Orange</option>
<option value ="<?php echo (htmlentities($contact['teamFlight']));?>"
selected><?php echo (htmlentities($contact['teamFlight']));?></option>
</select>
<td class="cell_border"><?php echo $contact['region'] ;?></td>
<td class="cell_border"><?php echo $contact['regionName'] ;?></td>
<td class="cell_border">
<?php echo '<input type ="text"
style="background-color: #81F7F3;"
name ="regionID_ud[' . $contact['coachID'] . ']"
value="' . (htmlentities($contact['regionID'])) . '">'; ?><style="background-color: #81F7F3;">
</td>
<td class="cell_border"><?php echo $contact['coachLast'] . ", " . $contact['coachFirst'] ;?></td>
<?php
$teamType_convert = $contact['teamType'];
if ($teamType_convert == 1)
$teamType = "Select Team" ;
if ($teamType_convert == 2)
$teamType = "One of several Select Teams" ;
if ($teamType_convert == 3)
$teamType = "Fall Season" ;
?>
<td class="cell_border"><?php echo $teamType ;?></td>
<td class="cell_border"><?php echo $contact['teamRating'] ;?></td>
<td class="cell_border"><?php echo $contact['coachID'] ;?></td>
</tr>
<?php
} // end while loop
?>
</table>
<input name="submit" type="submit" value="Save"></form>
</body>
</html>
Thanks.
Robkir