I guess I am plain dense today--I still couldn't get it to work. I've included all the code (its work in progress so obviously there are some holes).
I thought I followed your instructions:
<td class="player_box">
<input name="<?php echo "playerRegion[$i]" ?> " type="text" value ="<?php echo $contact['playerRegion'];?>"
style="width: 40px; background-color: #81F7F3;"></td>
But it isn't updating. It's not the end of the world if you can't quickly find the fix, I can write it using the code I already know--it just seems like I should be able to do it with the PHP embedded in the HTML.
Here's the whole module:
<?php
session_start();
include('../validateUser_incl.php'); //checks to be sure that the user is logged in
require("../functions/checkEntries.php");
include_once "../DBconMOD.php";
include_once "../style_sheet.php";
$coachID="27";
print "Coach Id is " . $coachID;
if (count($error) == 0) {} //end count errors
//print "line 11 " . $_POST['addNewPlayer'] . " and update button says " . $_POST['updateRoster'] . "<br/>";
if($_POST['addNewPlayer'])
{ //addNewPlayer Start
$coachID=$_SESSION['idUser'];
$shirtNo = protect($_POST['shirtNo']);
$playerRegion= protect($_POST['playerRegion_ud']);
$playerAysoID= protect($_POST['playerAysoID_ud']);
$playerL= protect($_POST['playerL_ud']);
$playerF= protect($_POST['playerF_ud']);
$playerAge = $_POST['playerAge _ud'];
$playerDOB= $_POST['playerDOB_ud'];
$playerTel=$_POST['playerTel_ud'];
$add_master_sql="INSERT INTO `team_roster`
(coachID, shirtNo, playerRegion, playerAysoID, playerL, playerF, playerAge, playerDOB, playerTel)
VALUES
( '$coachID' ,
'$shirtNo' ,
'$playerRegion' ,
'$playerAysoID' ,
'$playerL' ,
'$playerF' ,
'$playerAge' ,
'$playerDOB' ,
'$playerTel'
)";
$add_master_res = mysql_query($add_master_sql,$link)
or die(mysql_error($link));
//mysql_close($link);
} //addNewPlayer End
// UPDATE Records
if($_POST['updateRoster'])
{
$size = count($_POST['shirtNo']);
// start a loop in order to update each record
$i = 0;
while ($i < $size)
{
$playerID = $_POST['playerID'][$i];
$shirtNo= $_POST['shirtNo'][$i];
$playerRegion= $playerRegion[$i];
$playerAysoID= $playerAysoID[$i];
$playerL= $playerL[$i];
$playerF= $playerF[$i];
$playerAge = $playerAge[$i];
$playerDOB= $playerDOB[$i];
$playerTel=$playerTel[$i];
$query = "UPDATE team_roster SET
shirtNo = '$shirtNo' ,
playerRegion= '$playerRegion' ,
playerAysoID= '$playerAysoID' ,
playerL= '$playerL' ,
playerF= '$playerF' ,
playerAge = '$playerAge' ,
playerDOB= '$playerDOB' ,
playerTel='$playerTel'
WHERE playerID = '$playerID'LIMIT 1";
mysql_query($query) or die ("Error in query: $query");
++$i;
}
//mysql_close();
}
?>
<!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" />
<title></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">
<style type="text/css">
.text_right {
text-align: right;
}
.player_box{
border: 1px solid #000000;
text-align: center;
font-family: arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<img src="../artwork/CupLogo.png" width="265" height="94"><span class="red_italic_text_medium">Roster Form
NEW PLAYER</span><hr>
<!-- BUTTONs -->
<form action="roster_add_new_player.php" method="post">
<input type="submit" name ="roster"value="Fill In ROSTER">
<input type="submit" name ="referee"value="BACK to Team Application">
<input type="submit" name ="toExit"value="EXIT Program">
<input type="submit" name ="printApp"value="PRINT Ref Form"><br>
<hr>
</form>
<!-- Error checking (Not written yet) -->
<?php if (!empty($error)): ?>
<p class="error">
<?php implode('<br />',$error) ?>
</p>
<?php endif; ?>
<?php
foreach($error AS $errors)
{
echo "<span class = \"text_reg\"> <strong><font color =\"red\">" . $errors . "</font></strong></span>\n";
}
?>
Player ID #: The National AYSO Registration Number, Region #: Region in which player is registered.
To remove a player, check the Del (for delete) box and click the ADD/UPDATE button<br>
<br>
Update Change Player Information<br>
<br>
<!-- Update Existing Player -->
<form action="roster_add_new_player.php" method="post">
<table style="width: 100%">
<tr>
<th class="player_box" size="2">Shirt #</th>
<th class="player_box" size="5">Region #</th>
<th class="player_box" size="5">Player ID #</th>
<th class="player_box" size="5">Player Name<br>Last / First</th>
<th class="player_box" size="5">Age</th>
<th class="player_box" size="5">Date of<br>Birth</th>
<th class="player_box" size="5">Telephone</th>
<th class="player_box" size="5">Del</th>
</tr>
<?php
$i = 0;
$result=mysql_query("SELECT * FROM team_roster WHERE coachID = '27' ORDER BY shirtNo");
while ($contact = mysql_fetch_array($result))
{
print "<input type='hidden' name='playerID[$i]' value='{$contact['playerID']}' />";
?>
<tr>
<td> <?php echo "<input type =\"text\" name = \"shirtNo[$i]\" value =\"{$contact['shirtNo']}\">" ?>
<td class="player_box">
<input name="<?php echo "playerRegion[$i]" ?> " type="text" value ="<?php echo $contact['playerRegion'];?>"
style="width: 40px; background-color: #81F7F3;"></td>
<td class="player_box"><input name="<?php echo "playerAysoID[$i]" ?> " type="text" value ="<?php echo $contact['playerAysoID'];?>"
style="width: 135px; background-color: #81F7F3;"></td>
<td class="player_box"><input name="<?php echo "playerL[$i]" ?> " type="text" value ="<?php echo $contact['playerL'];?>"
style="width: 135px; background-color: #81F7F3;">
<input name="<?php echo "playerF[$i]" ?> " type="text" value ="<?php echo $contact['playerF'];?>"
style="width: 135px; background-color: #81F7F3;"></td>
<td class="player_box"><input name="<?php echo "playerAge[$i]" ?> " type="text" value ="<?php echo $contact['playerAge'];?>"
style="width: 40px; background-color: #81F7F3;"></td>
<td class="player_box">
<input name="<?php echo "playerDOB[$i]" ?> " type="text" value ="<?php echo $contact['playerDOB'];?>"
style="width: 57px; background-color: #81F7F3;"></td>
<tdclass="player_box"></td>
<td class="player_box">
<input name="deleteMe[$i]" type="checkbox"
style="width: 30px; background-color: #81F7F3;"></td>
</tr>
<?php $i++; } //close While Loop for update existing player ?>
</table>
<input type="submit" name="updateRoster" value="Update Roster" />
</form>
</body>
</html>