try something like the following
PHP Code:
<?php
if(isset($_GET['match_id']))
{
$result = mysql_query("Select * From player_stats where match_id=".$_GET['match_id']);
foreach($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$name = $row['name'];
$goals = $row['goals'];
$match_id = $row['match_id'];
$html .= "<tr>\n";
$html .= "<td width=\"33%\">Goalkeeper:</td>";
$html .= "<td width=\"33%\"><input name=\"r[goalkeeper][name]\" type=\"text\" value=\"".$name."\" size=\"36\" /></td>\n";
$html .= "<td width=\"33%\"><input name=\"r[goalkeeper][goals]\" type=\"text\" value=\"".$goals."\" size=\"36\" /></td>\n";
$html .= "</tr>\n";
}
}
if(isset($_POST['Submit']))
{
foreach($_REQUEST['r'] as $position => $row)
{
$x = implode("', '",$row);
$position = $x[0];
$name = $x[1];
$result = mysql_query("UPDATE player_stats SET position='$position', name='$name', goals='$goals', match_id='$match_id' WHERE match_id=".$_GET['match_id']);
}
}
?>
<!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-Type" content="text/html; charset=utf-8" />
<title>Player stats</title>
</head>
<body>
<form name="statistics" method="post" action="">
<table width="100%">
<tr>
<td width="33%">Player</td>
<td width="33%">Name</td>
<td width="33%">Goals</td>
</tr>
<?php echo $html; ?>
</table>
<input type="submit" name="Submit" value="Submit"/>
</form>
</body>
</html>
Also you should blindly use $_GET in the query without making sure it's what you expecting. try at least using mysql_real_escape_string() or something.
Bookmarks