Capturing dynamic number of form element

Dear All,
I have a link here Untitled Document. What you need to do is select the a layout value then click on the select button you will get a pop-up window. In the pop-up window you can click on the checkbox and the select name will change. For e.g. my first layout I got only 4 tyre so I have row1 tyre[‘F1L’],tyre[‘F1R’] , row2 tyre[‘R1L’],tyre[‘R1R’]. Second one I got row1 tyre[‘F1L’],tyre[‘F1R’] , row2 tyre[‘R1L’],tyre[‘R1R’], row3 tyre[‘R2L’],tyre[‘R2R’]. So how on the php I should capture it based on this two example? In php I can have this $tyre= (array) $_POST[tyre]; right. Is is possible for me to capture based on rows?

It depends entirely on how you lay out your form. Because you dont actually have -dynamic- form elements (you have 4 set layouts), your script should be able to read the value of the layout dropdown, and then read the $_POST array respectively.

Dear Star,
I agree at times a row will have 2 or some times it will have 4 values. So how best to handle it well? Any idea? The 4 set of layouts is just a sample it will keep adding more layouts latter.

well your form will pass the value of the layout - so your script can just throw a [FPHP]switch[/FPHP] to handle the different formats.

Dear Star,
I am not so clear with your switch idea because I am worried it can become a lot of values for some of the layouts. Any code snippet to show me the idea?

switch($_POST['layout']) {
  case '2x4':
     $locations = array('FL','FR','RL','RR');
  case '2x6'
    $locations = array('F1L','F1R','F2L','F2R','RL','RR');
foreach($locations AS $location) {
  $tyre[] = $_POST[$location];

Dear Star,
So there is not other mechanism to handle this right? In this case I have to first get all my layouts ready first right?

I dont understand your question. How else would you want to handle it? What do you want to DO with this data?

Dear Start,
My question is that the number of layouts will be more then what I have. So according to your method I have to prepare the layout in the codes statically is it? Thank you.

Again, it depends on what you want to do with the data (and specifically, whether integrity of position is paramount). What’s your goal?

Dear Star,
What I want to do with the posted data is to store back into the database accordingly to the relevant fields.

(Rudy will probably show up and smack my hand for suggesting this.)

So make your tyre selection names an array (<select name=‘tyre[F1R]’> … )

foreach($_POST['tyre'] AS $key => $value) {
 $tyre[] = "$key:$value";
$sql->query("INSERT INTO tyreinfo(tyres) VALUES('".implode(';',$tyre)."')");

Yes, you could also do it by making a separate table to hold the values for each tyre.

Dear Star,
Ok nvm I shall try your new idea n see how it works. I got another idea what I think I can do is first based on the layoutID I go n get the details for each row on the layout and then read the post value. So I have for loop and subsitute the $_POST[‘valueFromDB’]. Do you think that is fine? Thank you.