title: how to store the data of multiple numbers of fields of form?
body: <p>I have a form in which user can increase or add numbers of fields as he wants.</p>
  
  <p>the fields are adding successfully.....</p>
  
  <p>for this I use javascript and  the code is here..</p>
  
  <pre><code>&lt;script type="application/javascript"&gt;
  var counter3 = 0;
  function addAuthor() {
      // Get the main Div in which all the other divs will be added
      var mainContainer = document.getElementById('Author');
  
      // Create a new div for holding text and button input elements
      var newDiv = document.createElement('div');
  
      // Create a new text input
      var newText = document.createElement('input');
      newText.type = "text";
      //var i = 1;
      newText.name = "Author[]";
      //newText.value = counter3 + 2 + ". ";
  
      //Counter starts from 2 since we already have one item
      //newText.class = "input.text";
      // Create a new button input
      var newDelButton = document.createElement('input');
      newDelButton.type = "button";
      newDelButton.value = "-";
  
      // Append new text input to the newDiv
      newDiv.appendChild(newText);
      // Append new button input to the newDiv
      newDiv.appendChild(newDelButton);
      // Append newDiv input to the mainContainer div
      mainContainer.appendChild(newDiv);
      counter3++;
      //i++;
  
      // Add a handler to button for deleting the newDiv from the mainContainer
      newDelButton.onclick = function() {
          mainContainer.removeChild(newDiv);
          counter3--;
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>and I have a form here..</p>
  
  <pre><code>&lt;form method="post" action=""&gt;
      &lt;input type = "text" name="Author[]" /&gt;
      &lt;input type="button" value="+" id="Authorbutton" onclick="addAuthor()" /&gt;
      &lt;input type="submit" value="submit" name="submit"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I use php and mysql queries to save the data into database..
  and the code code is..</p>
  
  <pre><code>&lt;?php
  
  if(isset($_POST['submit']))
  {
  $authors = $_POST['Author'];
  foreach($authors as $author) 
  {
      $sql=mysql_query("INSERT INTO test (number, type) VALUES ('{$_POST['type']}','{$author}')");
  
      if (!$sql){
         die('Error: ' . mysql_error());
      }
  //endforeach;
  
  }
  }
  
  ?&gt;
  </code></pre>
  
  <p>but the problem is that the data does not store properly in database...</p>
  
  <p>it saves only the first field in the database but not for 2nd, 3rd, 4th and so on...</p>
  
  <p>help me ........</p>