title: array not working for dynamic form field
body: <p>I've found most of the pieces i've needed for this form (making the fields dynamic, etc.) however now the array part of this doesn't seem to work to be able to submit correctly.</p>
  
  <p>what i'm trying to accomplish:
  a form with a select field that can be duplicated dynamically and then be submitted as a part of the form to it's own table. so if we add and choose three people in the one form, it submits to it's own attending table with a foreign key back to the event the form is for. had to make it dynamic because we'll never know for sure how many people will be attending said event, but it has to happen all in one form. just because it does. my boss says so.</p>
  
  <p>here's my javascript for the add another field button:</p>
  
  <pre><code>    $(document).ready(function() {
          $('#btnAdd').click(function() {
              var num     = $('.clonedInput').length; // how many "duplicatable" input fields we currently have
              var newNum  = new Number(num + 1);      // the numeric ID of the new input field being added
  
              // create the new element via clone(), and manipulate it's ID using newNum value
              var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
  
              // manipulate the id value of the input inside the new element
              newElem.children(':first').attr('id', 'attendee' + newNum).attr('name', 'attendee[' + newNum + ']');
  
              // insert the new element after the last "duplicatable" input field
              $('#input' + num).after(newElem);
  
              // enable the "remove" button
              $('#btnDel').attr('disabled','');
  
              // business rule: you can only add 5 names
              if (newNum == 6)
                  $('#btnAdd').attr('disabled','disabled');
          });
  </code></pre>
  
  <p>here's what the field starts out as in the form:</p>
  
  <pre><code>    &lt;div id="input1" style="margin-bottom:4px;" class="clonedInput"&gt;
      &lt;select name="attendee[1]" id="attendee1" style='float:right;margin-right:4.5%;'&gt;
      &lt;option value=''&gt;Please choose one...&lt;/option&gt;
      &lt;?php
      while($row_attendees = mysql_fetch_assoc($res_attendees)){
          $attendee_id = $row_attendees['attendee_id'];
          $attendee_name = $row_attendees['name'];
  
          echo "&lt;option value='".$attendee_id."'&gt;".$attendee_name."     &lt;/option&gt;";
      }
      ?&gt;
      &lt;/select&gt;&lt;label style='width:100px;display:inline-block;line-height:28px;' for="attendee"&gt;Attendee&lt;/label&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>I'm getting all the things to change correctly. all of the select inputs are being id'd and name'd correctly. the div is being updated the same. all of that works correctly. what doesn't is when i go to submit. here's my php:</p>
  
  <pre><code>    foreach($_POST['attendee'] as $attendee){
      $sql_attendees = "INSERT into marketing_calendar.attending (event_title, attendee_id) VALUES ('".$_POST['title']."','".$attendee."')";  
      $res_attendees = mysql_query($sql_attendees) or die(mysql_error());
  }
  </code></pre>
  
  <p>all the tutorials i used to pull this together show this as correct. however it doesn't work. i'm only getting whatever the first dropdown is, and nothing else is populating into the array. at least that's all it shows/submits if i run the form or echo the attendee variable in the foreach statement. PLEASE HELP! :)</p>
  
  <p>thanks a ton in advance.</p>
  
  <p><strong>UPDATE</strong>
  I have tried a few ways discussed with another user to display the array for $_POST['attendee'], however it still just shows 1 id in the array, and not however many fields i've actually added. I've also tried removing the number from the array in the select's name attribute. so it would just be name='attendee[]' instead of name='attendee[1]' and so on. this also doesn't help any. can someone please help with why my dynamically added fields aren't being added to the array? </p>