title: Save multiple same named fields to database PHP
body: <p>The PHP CODE to save it.</p>
  
  <pre><code>$cols = $_POST['col'];
  
  $EvenementID = mysql_real_escape_string($_POST['evenementid']);
  
  foreach($cols as $col) {
  
  $Ticketnaam = mysql_real_escape_string($col['ticket']);
  $Aantal = mysql_real_escape_string($col['aantal']);
  $Prijs = mysql_real_escape_string($col['prijs']);
  
  $sql = "INSERT INTO tbl_Tickets (EvenementID, Ticketnaam, Aantal, Prijs) VALUES('".$EvenementID ."', '{$Ticketnaam}', '{$Aantal}', '{$Prijs}')";
  
  
  }
  </code></pre>
  
  <p>HTML CODE</p>
  
  <pre><code>&lt;input type="hidden" name="evenementid" value="&lt;?php echo $evenementid; ?&gt;" /&gt;
  </code></pre>
  
  <p>BLOCK 1</p>
  
  <pre><code>&lt;input type="text" name="col[0][ticket]" id="ticket" class="tekst-lang"/&gt;
  &lt;input type="text" class="tekst-lang" name="col[0][aantal]" id="aantal"/&gt;
  &lt;input type="text" class="tekst-lang" name="col[0][prijs]" id="prijs"/&gt;
  </code></pre>
  
  <p>BLOCK 2</p>
  
  <pre><code>&lt;input type="text" name="col[1][ticket]" id="ticket" class="tekst-lang"/&gt;
  &lt;input type="text" class="tekst-lang" name="col[1][aantal]" id="aantal"/&gt;
  &lt;input type="text" class="tekst-lang" name="col[1][prijs]" id="prijs"/&gt;
  </code></pre>
  
  <p>AJAX </p>
  
  <pre><code>var myData = $('#ticket-form').serialize();
  
                          $.ajax({
                              type: "POST",
  
                              //URL of the php file that will process the login
                              url: "includes/ticket.php",
  
                              dataType: 'json',
  
                              //Pass the data through
                              data: myData,
  
                              //Handle the response
                              success: function (data) {
  
                              switch(data.case){
  
                              case 1: 
                              $(".inlog-feedback").html(data.message).fadeIn('slow');
                              break;
  
                              case 2:      
                              $(".inlog-feedback").html(data.message).fadeIn('slow');
                              window.location = "index.php"; 
                              break;
  
                              case 3: 
                              $(".inlog-feedback").html(data.message).fadeIn('slow');
                              break;
  
                              default:
                              /* If none of the above */
  
                              }
                      }            
                          })  
  
                          //Stop the submit button from submitting the form 
                          return false;   
                          }  
  </code></pre>
  
  <p>I'm trying to save the 2 blocks to my database (So I need 2 records). Both blocks have the same evenementID. The problem is that there is only one record in the database.</p>