<?php
foreach ($_POST['farve'] as $key => $farve_output) {
print $farve_output;
echo ", ";
}
?>
<form method=POST>
<select name="farve[]" size=10 MULTIPLE>
<option>Grøn</option>
<option>Rød</option>
<option>Blå</option>
</select>
<input type="submit" name="submit" value="submit">
</form>
What I'm trying to do is to make a many to many relation in the MySQL database. Basically, what it handles is colours associated with products. The tables would look something like:
ProductID ---- ProductName
1 --------------- Product A
2 --------------- Product B
ColourID ----- Colour
1 -------------- Green
2 -------------- Red
3 -------------- Blue
ProductID --- ColourID
1 -------------- 1
1 -------------- 2
1 -------------- 3
2 -------------- 3
...Basically for every colour that is added a new row needs to be created in the ProductID - ColourID table. I already made the select form and I already got it to output several 'arrays', what I wonder is, how can I make it handle the values it output as 'individual' values? So that it knows if I have added Grøn (Green), Rød (Red) and Blå (Blue), it will make a seperate row in a MySQL table for each of them. (3 rows)?
Help would be much appreciated