<input type="hidden" name="arrco[0]" value="0">
<?php foreach ($ob->selectdata("select * from tb_attribute") as $key => $attributes) {
?>
<td>
<select name="<?php echo(strtolower($attributes['attribute_name'])); ?>[0]" class="form-control variation">
<?php
$prdvar = $ob->selectdata("select * from tb_variations where attr_id='" . $attributes['attr_id'] . "'");
foreach ($prdvar as $variations) {
?>
<option value="<?php echo($variations['variations_name']); ?>"><?php echo($variations['variations_name']); ?></option>
<?php
}
?>
</select>
</td>
<?php } ?>
Here select box name is table values, when i click on add more button it clone the entire row. its working perfectly.
But in my action page how can i save the posted values
arrco is the table count its value incremented in jquery
<?php
extract($_POST);
foreach($arrco as $key => $arrcoval)
{
foreach($arrco as $key => $arrcoval)
{
foreach($obsec->selectdata("select * from tb_attribute") as $key1 => $attributes)
{
$verat = ($_POST[strtolower($attributes['attribute_name'])][$key]);
echo $key.'-'.$verat."<br>";
}
}
}
?>
Here is my table structure
Table tb_attribute
attr_id | attribute_name
--------------------------
1 | Size
2 | Color
Table tb_variations
id | attr_id | variations_name
-----------------------------------
1 | 1 | XL
2 | 1 | SM
3 | 2 | Red
4 | 2 | Black
Now it shows
0-SM
0-Red
1-XL
1-Black
2-XL
2-Red
But I want to show
0 - SM - Red
1 - XL - Black
2 - XL - Red
i enter 3 rows but its shows 6 times
Please help me