title: how to save dynamic form data from javascript to database with a query
body: <p>So I have a script that makes dynamic form content and each input has a name of "field-1", "field-2", etc. up until the last input is created by the script.</p>
  
  <p>How can I save the form made to the database?</p>
  
  <p>I only know how to do this in a traditional way where you make like 5 static inputs and give them static names and ids then use the either post or get go formulate the mysql_query.</p>
  
  <p>But in my case, the inputs can range from 3 - 200 inputs. and each have a similar name/id of "field+num++"</p>
  
  <p>My html code:</p>
  
  <pre><code>&lt;form id="myForm"&gt;
  </code></pre>
  
  <p>My JS code that will append to my HTML form:</p>
  
  <pre><code>var $int = $('div.int');
  $int.html(function(i, html) {
      return html.replace(/(\d+)(.+)/,function(str,s1,s2){
          var text = s2.split('.');
          var text2 = text[1].split('-');
          var text3 = text2[1].split(' ');
          return '&lt;input class="r" name="scene-"' + s1 + ' value="'+ s1.replace(/^\s*/, '').replace(/\s*$/, '') +'" /&gt;' +
          '&lt;input class="r" name="int_ext-"' + s1 + ' value="'+ text[0].replace(/^\s*/, '').replace(/\s*$/, '') +'" /&gt;' +
          '&lt;input class="r" name="scene_desct-"' + s1 + ' value="'+ text2[0].replace(/^\s*/, '').replace(/\s*$/, '') +'" /&gt;' +
          '&lt;input class="r" name="day_night-"' + s1 + ' value="'+ text3[1].replace(/^\s*/, '').replace(/\s*$/, '') +'" /&gt;';
      });
  });
  </code></pre>
  
  <p>My HTML code:</p>
  
  <pre><code>&lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>a sample output is:</p>
  
  <pre><code>&lt;input type="text" class="r" name="scene-1" value="1" /&gt;
  &lt;input type="text" class="r" name="int_ext-1" value="INT" /&gt;
  &lt;input type="text" class="r" name="scene_desct-1" value="Bedroom" /&gt;
  &lt;input type="text" class="r" name="day_night-1" value="DAY" /&gt;
  
  &lt;input type="text" class="r" name="scene-2" value="2" /&gt;
  &lt;input type="text" class="r" name="int_ext-2" value="EXT" /&gt;
  &lt;input type="text" class="r" name="scene_desct-2" value="Outside" /&gt;
  &lt;input type="text" class="r" name="day_night-2" value="DAY" /&gt;
  
  &lt;input type="text" class="r" name="scene-3" value="3" /&gt;
  &lt;input type="text" class="r" name="int_ext-3" value="INT" /&gt;
  &lt;input type="text" class="r" name="scene_desct-3" value="Bedroom" /&gt;
  &lt;input type="text" class="r" name="day_night-3" value="DAY" /&gt;
  
  &lt;input type="text" class="r" name="scene-4" value="4" /&gt;
  &lt;input type="text" class="r" name="int_ext-4" value="EXT" /&gt;
  &lt;input type="text" class="r" name="scene_desct-4" value="Bedroom" /&gt;
  &lt;input type="text" class="r" name="day_night-4" value="NIGHT" /&gt;
  
  ...
  
  more are created on the fly with the script, this can make like 300 sets of these 4 inputs
  </code></pre>
  
  <p>then I would like to do something like </p>
  
  <pre><code>mysql_query("INSERT INTO `table` (`scene_num`, `int_ext`, `scene_desct`, `day_night`) VALUES ('{$scene}', '{$int_ext}', '{$scene_desct}', '{$day_night}')");
  </code></pre>