title: php add multiple input fields to mysql
body: <p>I have this code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;form id="myForm" method="post" action="add-data.php"&gt; 
          &lt;input type="submit"&gt;
          &lt;input type="text" name="pollquestion"&gt; 
          &lt;input type="text" name="polloption1"&gt; 
          &lt;input type="text" name="polloption2"&gt; 
  &lt;/form&gt; 
  &lt;a href="javascript:addOption();"&gt;Add option&lt;/a&gt; 
  
  &lt;script&gt; 
          var optionNumber = 3;
          function addOption() { 
                  var theForm = document.getElementById("myForm"); 
                  var newOption = document.createElement("input"); 
                  newOption.name = "polloption"+optionNumber+""; // poll[optionX]
                  newOption.type = "text";
                  theForm.appendChild(newOption); 
                  optionNumber++;
          } 
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>If i add more inputs i will have something like this:</p>
  
  <pre><code>&lt;input name="pollquestion" type="text"&gt;
  &lt;input name="polloption1" type="text"&gt;
  &lt;input name="polloption2" type="text"&gt;
  &lt;input name="polloption3" type="text"&gt;
  &lt;input name="polloption4" type="text"&gt;
  &lt;input name="polloption5" type="text"&gt;
  &lt;input name="polloption6" type="text"&gt;
  </code></pre>
  
  <p>The php code is something like this:</p>
  
  <pre><code>$qu = $_POST['pollquestion'];
  $op1 = $_POST['polloption1'];
  $op2 = $_POST['polloption2'];
  $query = "INSERT into `".$db_table."` (question, option1, option2) VALUES ('" . $qu . "','" . $op1 . "','" . $op2 . "')";
  </code></pre>
  
  <p>How can i add this data to mysql for every added row? Thanks!</p>