I have a table whose contents based id_product, when I edit the automatic reference is the id_product, and there are data from multiple should I pull and I give them one data of the field how to put the data from multiple database to form input type file and form input type dropdown (SELECTED).
my table color :
+--------------------------------------+
| id_color | id_product | option_color |
----------------------------------------
| 1 | 20 | white |
| 2 | 20 | black |
+--------------------------------------+
results should be like this :
<select type="select" name="color[]">
<option value="">blue</option>
<option value="" selected="selected">white</option>
<option value="">black</option>
</select>
<select type="select" name="color[]">
<option value="">blue</option>
<option value="">white</option>
<option value="" selected="selected">black</option>
</select>
my table image :
+--------------------------------------+
| id_image | id_product | image |
----------------------------------------
| 32 | 20 | pro1.jpg |
| 33 | 20 | bl23.jpg |
+--------------------------------------+
results should be like this :
<input type="file" name="additional_image[]" value="pro1.jpg">
<input type="file" name="additional_image[]" value="bl23.jpg">
</div>
<?
$colors = array(
0 => 'blue',
1 => 'white',
2=> 'black'
);
$products = array(
array(
'id_color' => 1,
'id_product' => 20,
'option_color' => 'white',
),
array(
'id_color' => 2,
'id_product' => 20,
'option_color' => 'black',
),
);
foreach ($products as $pro) { ?>
<select type="select" name="color[]"><?
foreach ($colors as $cid =>$color) { ?>
<option value="" <? echo $pro['id_color']==$cid?'selected="selected"':'';?> ><? echo $color; ?></option>
<? }
?></select>
<? } ?>