title: PHP loop through array to update SQL database
body: <p>I am trying to loop through an array ($lineup_selected) that corresponds to a player row in a database. For each player I would like to execute an UPDATE query to the database that adds the value of $submissions_selected to the total_picks column. I am struggling with the code as it fails to execute the query. Any help please?!</p>
  
  <pre><code>// Select team &amp; formation
  $team_selected = "team1";
  $lineup_selected = array("player1", "player2", "player3");
  $submissions_selected = 4000;
  
      // Loop through and update total_picks for each player in database present in lineup_selected array
      $player_picks_query = "SELECT full_name, total_picks FROM table WHERE team=$team_selected";
      $result = mysqli_query($conn, $player_picks_query);
  
      while($row = mysqli_fetch_assoc($result)) {
  
          $player = mysql_real_escape_string($row["full_name"]);
  
          $add_player_picks = "UPDATE table 
                      SET total_picks = total_picks + $submissions_selected
                      WHERE full_name = '$player'";
  
      }
  </code></pre>