title: mysqli multiple insert not submitting all lines from array
body: <p>I have a big issue with my code I suspect.
  It only adds the first of <code>$species</code>, <code>$weight</code> and <code>$length</code>. but if there is more than one value in the <strong>$_Post</strong>. 
  It should submit them as well from my form. I am having trouble seeing where I have gone wrong. 
  I hope somebody, can point me in the right direction?</p>
  
  <pre><code>&lt;?php
  
  require 'config.php';
  
  $teamid = $_POST['teamid'];
  $species = $_POST['species']; // Can be multiple values depending on how many lines added from form
  $weight = $_POST['weight']; // Can be multiple values depending on how many lines added from form
  $length = $_POST['length']; // Can be multiple values depending on how many lines added from form
  
  // count($species),($weight),($length) - Should always be the same length
  
  // Processing form data when form is submitted
  if($_SERVER["REQUEST_METHOD"] == "POST"){
  
          // Prepare an insert statement
          $sql = "INSERT INTO indvejninger ( teamid, artid, vaegt, laengde) VALUES (?, ?, ?, ?)";
  
          if($stmt = $mysqli-&gt;prepare($sql)){
  
              foreach ($species as $key =&gt; $value) {
  
              // Bind variables to the prepared statement as parameters
              $stmt-&gt;bind_param("ssss", $_POST['teamid'], $param_species, $param_weight, $param_length);
  
              $param_species = $species[$key];
              $param_weight = $weight[$key];
              $param_length = $length[$key];
  
              // Attempt to execute the prepared statement
              if($stmt-&gt;execute()){
                  // Records created successfully. Redirect to landing page
                  header("location: index.php?limit=");
                  exit();
              } else{
                  echo "Something went wrong. Please try again later.";
              }
          }       
  
          // Close statement
          $stmt-&gt;close();
  
          }
  
      // Close connection
      $mysqli-&gt;close();
  }
  </code></pre>