title: Submitting values of "jQuery Editable Invoice" into a MySQL DB using PHP
body: <p>I am using <a href="http://css-tricks.com/editable-invoice-v2/" rel="nofollow noreferrer">this</a> fantastic example of a jQuery editable invoice as a template for creating dynamic invoices for my users.</p>
  
  <p>It's working quite well and I am successfully generating the items but I now need to save the values entered into the various text fields and enter them into the MySQL database.</p>
  
  <p>I am confident in doing the MySQL entering with PHP but what makes this trickier is that the amount of 'invoice items' is completely dynamic and I am unsure how I can get PHP to 'check' through the pages text fields and find new ones, group them and then add them to my DB.</p>
  
  <p>Here is an example of my code that I am using to generate the items:</p>
  
  <pre><code>&lt;?php if($invoice_items-&gt;result_array()) { ?&gt;
  &lt;?php foreach($invoice_items-&gt;result_array() as $invoice_Row): ?&gt;
      &lt;tr class="item-row"&gt;
              &lt;td class="item-name"&gt;
              &lt;div class="delete-wpr"&gt;
                  &lt;textarea&gt;&lt;?php echo $invoice_Row['item_name']; ?&gt; Facility Booking&lt;/textarea&gt;
                  &lt;a class="delete" href="javascript:;" title="Remove row"&gt;X&lt;/a&gt;
              &lt;/div&gt;
          &lt;/td&gt;
              &lt;td class="description"&gt;
                  &lt;textarea&gt;&lt;?php echo $invoice_Row['description']; ?&gt;&lt;/textarea&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;textarea class="cost"&gt;$&lt;?php echo $invoice_Row['hourly_cost']; ?&gt;.00&lt;/textarea&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea class="qty"&gt;&lt;?php echo $total_time_hours; ?&gt;&lt;/textarea&gt;&lt;/td&gt;
              &lt;td&gt;&lt;span class="price"&gt;$&lt;?php $unit_total = $invoice_Row['hourly_cost']* $total_time_hours; echo $unit_total;?&gt;.00&lt;/span&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;?php endforeach; ?&gt;
  &lt;?php } ?&gt;  
  </code></pre>
  
  <p>I am thinking that I need to perhaps generate unique ID's for each invoice items text field, ie <code>item-1-desc</code>, <code>item-1-cost</code> etc, but that involves writing javascript which I know almost nothing about. Also I would still have to get PHP to loop through the ID's somehow until it reached the end...</p>
  
  <p>If anyone has attempted something similar before or you can see a solution to my problem I would greatly appreciate your help.</p>
  
  <p>Thanks,</p>
  
  <p>Tim</p>