Hi All,
I have a script which outputs data from a database and puts it in a league table using mysql_fetch_array:
<?php
// Start the connection to the database
//whoosh
// End the connection to the database
// Get the data from the league table
$databaseInfo = mysql_query("SELECT * FROM `league_table` WHERE league='p' ORDER BY team_points_total DESC, team_gf-team_ga DESC") or die(mysql_error());
if(isset($_POST['Submit']))
{
$team_wins = $_POST['team_wins'];
$team_draws = $_POST['team_draws'];
$team_losses = $_POST['team_losses'];
$team_gf = $_POST['team_gf'];
$team_ga = $_POST['team_ga'];
$team_points_total = $_POST['team_points_total'];
if(!isset($_GET['table_id']))
{
$result = mysql_query("Update league_table set team_wins='$databaseArray['team_wins']' ");
$msg = "League Table Updated";
}
} //End of POST submit
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../../../include/styles.css">
</head>
<body>
<table width="937" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF">
<form name="table" method="post" action="">
<table width="100%" bgcolor="#999999">
<tr bgcolor="#0066CC">
<td width="17%"><strong><font color="#FFFFFF">Team</font></strong></td>
<td width="7%"><strong><font color="#FFFFFF">Won</font></strong></td>
<td width="7%"><strong><font color="#FFFFFF">Drawn</font></strong></td>
<td width="9%"><strong><font color="#FFFFFF">Lost</font></strong></td>
<td width="7%"><strong><font color="#FFFFFF">Goals For</font></strong></td>
<td width="14%"><strong><font color="#FFFFFF">Goals Against</font></strong></td>
<td width="39%"><strong><font color="#FFFFFF">Points</font></strong></td>
</tr>
<?php while ($databaseArray = mysql_fetch_array($databaseInfo)){ ?>
<tr bgcolor="#FFFFFF">
<td><?php echo $databaseArray['team_name']; ?></td>
<td> <input name="team_wins" type="text" id="team_wins" value="<?php echo $databaseArray['team_wins']?>" size="12" />
</td>
<td> <input name="team_draws" type="text" id="team_draws" value="<?php echo $databaseArray['team_draws']?>" size="12" />
</td>
<td> <input name="team_losses" type="text" id="team_losses" value="<?php echo $databaseArray['team_losses']?>" size="12" />
</td>
<td> <input name="team_gf" type="text" id="team_gf" value="<?php echo $databaseArray['team_gf']?>" size="12" />
</td>
<td> <input name="team_ga" type="text" id="team_ga" value="<?php echo $databaseArray['team_ga']?>" size="12" />
</td>
<td> <input name="team__points_total" type="text" id="team__points_total" value="<?php echo $databaseArray['team__points_total']?>" size="12" />
</td>
</tr>
<?php } // end of while loop ?>
</table>
<br /> <input type="submit" name="Submit" value="Submit" class="button">
<input type="reset" name="Reset" value="Reset" class="button">
</form>
</td>
</tr>
</table>
</body>
</html>
Now this pulls out all 40 records of rows and displays on the webpage great, but if I want to UPDATE any record values in all of the records pulled out of the database and hit submit they are all are set to 0. Can anyone see why is there something obvious I’m missing in my update statement?
Thanks
Chris