title: Why is my form only passing input data from last field within foreach loop to database?
body: <p>I am trying to update some data in my database from a form with this foreach loop:</p>
  
  <pre><code>$players_ids = $_POST['player_ids'];
  
      foreach($players_ids as $player_id) {
  
          foreach($_POST['goals'] as $goals) {
  
              var_dump($goals);
              $updateGoals = \DB::table('stats')-&gt;where('id', $player_id)-&gt;update(['goals' =&gt; $goals]);
          }
  
          foreach($_POST['assists'] as $assists) {
  
              var_dump($assists);
              $updateAssists = \DB::table('stats')-&gt;where('id', $player_id)-&gt;update(['assists' =&gt; $assists]);
          }
  
          foreach($_POST['tackles'] as $tackles) {
  
              var_dump($tackles);
              $updateTackles = \DB::table('stats')-&gt;where('id', $player_id)-&gt;update(['tackles' =&gt; $tackles]);
          }
  
      }
  </code></pre>
  
  <p>Here is the form:</p>
  
  <pre><code>@foreach($players as $player)    
  
  &lt;tr&gt;
      &lt;input type="hidden" name="player_ids[]" value="{{ $player-&gt;id }}"&gt;
      &lt;input type="hidden" name="game_id" value="{{ $game-&gt;id }}"&gt;
      &lt;td&gt;{{ $player-&gt;fn }} {{ $player-&gt;ln }}&lt;/td&gt;
      &lt;td&gt;&lt;input type="number" value="0" name="goals[]" placeholder="goals"&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="number" value="0" name="assists[]" placeholder="assists"&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type="number" value="0" name="tackles[]" placeholder="tackles"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  @endforeach
  </code></pre>
  
  <p>When I try to submit this data, instead of passing through the individual stats of each player to the database, it only passes through the data of the last player in the foreach loop to every player. So if the final player has 3 goals, everyone will get 3 goals in the database. This is obviously not how I would like this to function. </p>
  
  <p>I know soon after this I will run into an issue with updating the data in my database, because I'm not looking to override what is already in the database, but instead add the value passed through to the value already in the database, so if anyone has any knowledge on that as well would be greatly appreciated.</p>