title: Adding multiple rows to table with auto_increment column
body: <p>Im trying to insert Data into a table named team. The table holds 4 colums. selection_id(primary key), player_name, position, and fixture id.</p>
  
  <p>The selection_id has a value of auto_increment. Im adding the player names and position to the table. However the problem is, for each value it extracts out of the arrays, $playnames and $positions, the selection_id updates. Like this: 
  <img src="https://i.stack.imgur.com/VQ86e.jpg" alt="enter image description here"></p>
  
  <p>This is not what I want. 5 names should be stored (thus storing the team selected) in the table <strong>before</strong> the selection_id updates. <strong>OR</strong> for each new row, where a new team selection is made, the selection_id must be the same.</p>
  
  <p>Im not sure how to get around this problem. I thought about doing another query after the data has been inserted to overwrite the selection_id and making all the rows (in this case) equal to 117. But im sure this is not the most effecient way to do it.</p>
  
  <p>If anyone can give me a couple of pointers it would be greatly appreciated.
  Code follows:</p>
  
  <pre><code>if ( isset($_POST['submit']) ) {
      $player_ids = array_map('intval', $_REQUEST['players']);
  
      var_dump($player_ids);
  
      $query = 'SELECT `name`, `position` 
          FROM `player_info` 
          WHERE `player_id` IN (' . implode(',', $player_ids) . ')';
  
      $return_names = mysql_query($query) or die(mysql_error());
  
      while ( $row = mysql_fetch_assoc($return_names) ) {
          $selected[] = $row['name'];
          $position[] = $row['position'];
      }
  
              for ($i=0; sizeof($selected) &gt; $i; $i++){
                   $sql = mysql_query("INSERT INTO `team`(`selection_id`,`player_position`,`player_name`) VALUES ('selection_id\"\"','$position[$i]','$selected[$i]')") 
                   or die(mysql_error());
                   echo $selected[$i]; 
                   echo $position[$i];
                       echo'&lt;br&gt;';
     }
   var_dump($selected);
            }
  </code></pre>