Hello All,
I'm building a site for statistical data for a five aside football team. So my team haw five players
- goalkeeper
- player_two
- player_three
- player_four
- player_five
and each match we play in is given a distinct match_id. For each player I want to record the following data:
position (ie goalkeeper, player_two)
name
goals
So when I come to submitting my data I want my table to eventually look like this after submit is hit on my form:

Now i've started building the design for the addition of this data, but got stuck. I have two questions
1) How can I specify the position of each player that is posted and get that data in the database?
2) When I hit submit 5 rows are saved, but with no data in them?
Can anyone help
Thank you
<?php
if(isset($_POST['Submit']))
{
$name = $_POST['name'];
$goals = $_POST['goals'];
$match_id=mysql_insert_id();
if(!isset($_GET['match_id']))
{
foreach($_REQUEST['r'] as $row)
{
$result = mysql_query("Insert into player_stats(name,goals,match_id)
values('$name','$goals','$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>
<tr>
<td width="33%">Goalkeeper:</td>
<td width="33%"><input name="r[1]name" type="text"></td>
<td width="33%"><input name="r[1]goals" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Two</td>
<td width="33%"><input name="r[2]name" type="text" /></td>
<td width="33%"><input name="r[2]goals" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Three</td>
<td width="33%"><input name="r[3]name" type="text" /></td>
<td width="33%"><input name="r[3]goals" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Four</td>
<td width="33%"><input name="r[4]name" type="text" /></td>
<td width="33%"><input name="r[4]goals" type="text" /></td>
</tr>
<tr>
<td width="33%">Player Five</td>
<td width="33%"><input name="r[5]name" type="text" /></td>
<td width="33%"><input name="r[5]goals" type="text" /></td>
</tr>
</table>
<input type="submit" name="Submit" value="Submit"/>
</form>
</body>
</html>