I ask the user how many players are on their roster and they select the answer from a drop down menu, click submit and it generates 1 roster spot for the amout of players they selected. Here is this code:

$players comes from the number they selected above.

$players = $_SESSION;
$i=1;
while($i<=$players){
echo "<tr><td><input name=player[$i][fname] type=text size=15/></td><td><input name=player[$i][lname] type=text size=15 /></td><td><input name=player[$i][jersey] type=text size=5 /></td><td><input name=player[$i][dob] type=text size=7 /></td><td><input name=player[$i][address] type=text size=15 /></td><td><input name=player[$i][city] type=text size=15 /></td><td><input name=player[$i][zipcode] type=text size=5 /></td><td><input name=player[$i][position] type=text size=15 /></td></tr>";
$i++;
}

Wwhen I do a submit to add each player to the database using a foreach loop all the data in every field says Array, not what they typed in.

I either have something wrong in the fields above or my foreach is messed up. Here is my foreach to add them to the DB:

$teamID = $_GET;

foreach($key as $c=> $value){

mysql_query("insert into tbl_rosters (teamID, fname, lname, jersey, dob, address, city, zipcode, position) VALUES ('$teamID', '".$_POST."','".$_POST."', '".$_POST."', '".$_POST."', '".$_POST."', '".$_POST."', '".$_POST."', '".$_POST."') ") or die(mysql_error());

}

I think you may need to use something like $_POST[$key] or $value

The latter should be the right one, because it's the current array in the loop.

This article has been dead for over six months. Start a new discussion instead.