Good day all!
I am using radio buttons in my team selection page,so that the manager can choose for what position which player must play,those radio buttons is for two positions, lets say position 1 and position 2 next to each players row, those data must then be submitted to the database to choose who is on which team.
The data submits to the database but only the last row of the table,not the ones that i choose.
Here is some of my code...
Language: PHP
echo "<table border=';1';>";
echo "<th colspan = ';4';>Team Selection</th>";
echo "<tr>";
echo "<th>player_id</th><th>Name</th><th>Surname</th><th>Position</th>";
echo "</tr>";
while ($row = mysql_fetch_array($result))
{
$player_id = $row[';player_id';];
$name = $row[';name';];
$surname = $row[';surname';];
$position = $row[';position';];
echo "<tr><td>$player_id</td><td>$name</td><td>$surname</td><td>$position</td><td>
<form method=';post'; action=';team_selection.php';>
<input name=';position1'; type=';radio'; value=';position1';>
position1
<input name=';position2'; type=';radio'; value=';position2';>
position2
<input type=';submit'; name=';add'; value=';add';>
</form>
</td></tr>";
}
echo "</table>";
///////////////this include function is too run the code to add the info on the database./////////////
if(isset($_POST[';add';]))
{
include(';add_team.php';);
}
The include function to add the info is
Language: PHP
$selection_id = $_POST[';selection_id';];
$position1= $_POST[';position1';];
$position2= $_POST[';position2';];
$query = "INSERT INTO teams (selection_id,fixture_id,position1,position2)
VALUES (';$selection_id';,';$fixture_id';,';$position1';,';$position2';);";
mysql_query($query);
header (';Location: team_selection.php';);
So the position1 and position2 is added to my database,but not the player in that same row,the player info of the last row is added only.With the add button in the while loop,every row gets a button and i want only that row i click on to be submitted to the database,not the last row.This must be a minor mistake somewhere but cannot seem to find that little bug.
Any help will be appreciated.