Here is my problem, hope someone can help.
I have a table "categories" structured like this.
category_id | title | type | values
21 | Resolution | multiselect | 800x600, 1024x768, 1280x1024
28 | Name | input | null
31 | Colour | input | null
..............
this information is taken from the database and acording to it's "type" filed listed.
for example
Code: Select all
<form name="test" action="add_records.php" method="post">
<table>
<tr>
<td>Resolution</td>
<td><select size="5" multiple name="cat[<?=$row['id'];?>]"><option value="800x600">800x600</option><option value="1024x768">1024x768</option><option value="1280x1024">1280x1024</option></select></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="cat[<?=$row['id'];?>]"></td>
</tr>
<tr>
<td>Colour</td>
<td><input type="text" name="cat[<?=$row['id'];?>]"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="save" name="submit_form"></td>
</table>
</form>the problems appear when I try to submit the form, because if I choose 2 or more values from the multiselect form, it takes me only the last record.
for example complete the form like this.
Resolution : 1024x768, 1280x1024 "this is a multiselect so I Ctrl select multiple values"
Name : Jim
Colour: red
When I submit the form I get
Array([21]=>"1280x1024", [28]=>"Jim", [31]=>"red")
And I need
Array([21]=>"1024x768", [21]=>"1280x1024", [28]=>"Jim", [31]=>"red")
This info is added into a table "products" wich has the following structure
id | product_id | category_id | values
and it should be added like this.
1 | 1 | 21 | 1024x768
2 | 1 | 21 | 1280x1024
3 | 1 | 28 | Jim
4 | 1 | 31 | Red
I would be very thankfull if you could help me solve the problem.
thankyou in advance.
Alin