Is it possible to construct a loop which takes every single value from an array and then updates a mysql table?
What the array looks like
output
Team Blue
4
4
Team Red
4
4
Bare in mind that the 4's are Id's.
Array code
$players = $lista;
shuffle($players);
$player_count = count($players);
$players_per_team = $player_count/2;
$teams = array_chunk($players,$players_per_team);
$team_1 = $teams[0]; // Lag 1
$team_2 = $teams[1]; // Lag 2
echo "Team Blue";
echo "<br>";
foreach ($team_1 as $value) {
echo $value . "<br>";
}
echo "<br>";
echo "Team Red";
echo "<br>";
foreach ($team_2 as $value) {
echo $value . "<br>";
}
How can i select each element in the array? Basically all i need to do is to update a single column for each id in both arrays.
See picture
https://gyazo.com/ceb49db66ba85b9a6adfa0daf30c7a57 I want to update "team" column.
My guess is that i need to make some sort of loop, but i have no clue on how to select each element and then querying it.
So my question is. How can i select each element in the array and loop some sort of query to update a single column?
If i need to provide more information, just tell me! Thank you for taking your time reading my question, kind regards Jonas