title: Forming an Array and/or List within PHP from an html form POST that contains an unknown number of values that are initially arranged by JavaScript
body: <p>First of all, hello and thank you for reading my question. This may seem like a slightly weird combination of requirements - and I am already aware that the problem is not beginning in the most efficient manner from the start, however this is a a prameter I am unable to change - at least at this time.</p>
  
  <p>I have an html form that contains two html tables. There is a range of JS calculation going on on each of these tables to calculate values in various readonly input fields from other (user) input fields. The final total of the first table is used after a calculation as the first value of the second table. The second table remains static and so has a defined number of inputs. This is not part of the problem <strong>but</strong> does rely on data in the first table.</p>
  
  <p>The first table has 6 input fields (3 text, one select and two textboxes) on one physical table row. There is also a button on this row which clones the entire row and then appends it below, adding an incremental value to each of the newly generated 6 fields. This allows the user to add as many rows as they require, each with the same 6 fields. The first (default) field has values such as:</p>
  
  <p>"texta_1", "textb_1", "textc_1", "textboxa_1" textboxb_1", "select_1"</p>
  
  <p>Any additional JS generated rows will follow the naming format to be:</p>
  
  <p>"texta_2", "textb_2", "textc_2", "textboxa_2" textboxb_2", "select_2"<br>
  "texta_3", "textb_3", "textc_3", "textboxa_3" textboxb_3", "select_3"<br>
  Etc</p>
  
  <p>There is no defined limit to how far/many this could be expanded to, although for the purposes this is intended to be used for mean that the small group who will use it and have access to it, will not need to input any more than 10 rows at a time.</p>
  
  <p>Everything up to this point functions perfectly. The issue is that once this form is posted, I need to collect ALL the data from the above mentioned table and be able to redisplay it to the user before it is saved into a mysql database.</p>
  
  <p>I need to know how, within php5 (5.3.3 being used on a LAMP stack - Debian/Apache2/MySQL 5.1.66/PHP 5.3.3) to collect <strong>all</strong> of the inputs for each of the 6 fields, and throw them into both a List and an Array. I'm not really sure which function I will require (my php abilities are both not top form and what there is of it, is 3 years out of date). The DB has correct provision for allowing all data in one area to be saved together - that is to say texta_1, texta_2, texta_3, texta_5 etc... will all want to be saved together in the DB in a column that is, lets say named "db_texta".</p>
  
  <p>I'll also need to throw data intended for/within each of these 6 DB columns into a foreach loop for displaying before submission to the DB and of course for later on when extracting it again from the DB.</p>
  
  <p>It might be important to point out that this part of the process is a <strong>step</strong> within an overall larger process. It is the second part of data collection and will not be the last part. It's preceded by the user entering in their personal details and this is submitted already into the DB before the above mentioned step commences, so there is already a DB entry in place awaiting this info, and once this is submitted to the DB there will be a third step which is required to allow the user to upload scanned images to associate with this entry. However I don't believe any of that is critical to this immediate problem. If I'm wrong about that, please just let me know!</p>
  
  <p><strong><em>How do I take what is posted within the initial form and list it nicely for review in correct format, and then glomp the unknown number of each of the 6 fields together to save into the DB, while also permitting me to extract and reuse the data later on?</em></strong></p>
  
  <p>I shall try to paste in there the PHP code I have at the moment. Please note it is not fully complete, but you can see the intention and where it is going - or trying to go!</p>
  
  <p><strong>CODE:</strong></p>
  
  <p>I've pasted the code at a paste service as it appears it slightly exceeds the maximum character space in here. I feel the overall code is useful to understand the full desired functionality. I'm trying to cover all the bases here before I post my first question. Apologies if this is the "not to do" thing here, though. :) The full code is visible at: <a href="http://pastie.org/8391018#" rel="nofollow">http://pastie.org/8391018#</a></p>
  
  <p><strong>Just to reiterate - the use of texta_[ ] style naming BREAKS the JS form functionality so this question is looking for an ALTERNATIVE method to achieve the requirements.</strong></p>
  
  <p>Replies and time appreciated, thank you!</p>