循环数组来更新mysql表

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

Google is your friend:

"php mysqli update column"

Best Result: https://www.w3schools.com/php/php_mysql_update.asp

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2";

if ($conn->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn->error;
}

$conn->close();
?>

Before you update or insert data check if your value are a integer

if (is_numeric($myArr[0])) {
    // number
} else {
    // something other
}