title: Retrieving data from dynamic form
body: <p>I have a form which is dynamically generated based on user input.</p>
  
  <p>Initially the user is shown 3 fields to select from (datefrom, dateto, and pitchtype), they select their options, click submit and the script generates a table with inputs for each date in the range for them to edit.</p>
  
  <p>An example of the generated form is below:</p>
  
  <pre><code>&lt;table id="avtable"&gt;
  
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Date&lt;/th&gt;
              &lt;th&gt;Current bookings&lt;/th&gt;
              &lt;th&gt;Max bookings&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
  
          &lt;form action="index.php?page=availability&amp;amp;task=edit&amp;amp;action=submit" method="post"&gt;&lt;/form&gt;
  
              &lt;input type="hidden" name="pitchtype" value="1" /&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;2012-05-13&lt;/td&gt;
                  &lt;td&gt;0&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" value="10" class="spinner" maxlength="3" name="max"&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;2012-05-14&lt;/td&gt;
                  &lt;td&gt;0&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" value="10" class="spinner" maxlength="3" name="max"&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;input type="submit" value="Save" name="Submit" /&gt;
  
          &lt;/form&gt;
  
      &lt;/tbody&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <p>In the recieving PHP file I need to be able to process the data for each date, and am clueless where to start! Typically if it was a static form I would just use something like</p>
  
  <pre><code>$max = $_REQUEST['max'];
  </code></pre>
  
  <p>To get the edited field.</p>
  
  <p>Obviously what I need to do is pair up each edited field with its date, for me to then process the data as I normally would. I presume I would need some sort of php loop with the array of data from the form, but I'm not quite sure where to start... any ideas?</p>
  
  <p>EDIT :</p>
  
  <p>I presume I would need to edit my outputed form to something like this, so the name of each input was the same as the date column, so what I need to know is then how to get all dates in the receiving php file:</p>
  
  <pre><code>&lt;table id="avtable"&gt;
  
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Date&lt;/th&gt;
              &lt;th&gt;Current bookings&lt;/th&gt;
              &lt;th&gt;Max bookings&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
  
      &lt;tbody&gt;
  
          &lt;form action="index.php?page=availability&amp;amp;task=edit&amp;amp;action=submit" method="post"&gt;&lt;/form&gt;
  
              &lt;input type="hidden" name="pitchtype" value="1" /&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;2012-05-13&lt;/td&gt;
                  &lt;td&gt;0&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" value="10" class="spinner" maxlength="3" name="2012-05-13"&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;2012-05-14&lt;/td&gt;
                  &lt;td&gt;0&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" value="10" class="spinner" maxlength="3" name="2012-05-14"&gt;&lt;/td&gt;
              &lt;/tr&gt;
  
              &lt;input type="submit" value="Save" name="Submit" /&gt;
  
          &lt;/form&gt;
  
      &lt;/tbody&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <p>Many thanks!</p>
  
  <p>Kevin</p>