title: Insert multiple same named fields into MySQL Database using PHP
body: <p>I have multiple fields with names that look like name_$i and I am trying to figure out a way to <strong>"on submit"</strong>, send them all to the database. The thing is that the form is looped and the insert has to be able to adapt to the number of fields in the form. Is there a way to do this???</p>
  
  <pre><code>&lt;?php
  
  $fldcnt = $_POST['fldcnt'];
  $i = $_POST['i'];
  
  for ($i = 0; $i &lt; $fldcnt; $i++){
  $NAME = $_POST['name_$i'];
  $AGE = $_POST['age_$i'];
  $ADDRESS = $_POST['address_$i'];
  $TELEPHONE = $_POST['telephone_$i'];
  $EMAIL = $_POST['email_$i'];
  
  
  
  $q_register_new_users = "insert into registration set
          NAME = '$NAME',
          AGE = '$AGE',
          ADDRESS = '$ADDRESS',
          TELEPHONE = '$TELEPHONE',
          EMAIL = '$EMAIL'";
  
      mysql_query($q_new_products,$connection) or die(mysql_error());
  
  
  };
  ?&gt;"
  </code></pre>