|
Posted by jack jackson on 10/20/66 11:18
HI I have a form which pulls values from the db, and thanks to help
from the irc chat, hopefully makes any checkboxes which are selected
part of an array to be gotten in post:
while ($media_rows = mysql_fetch_assoc($media_result)){
$checkbox_media[] = "<input type='checkbox' name='media_types[]'
value='{$media_rows['media_id']}' />{$media_rows['media_name']} ";
}
I'd like to now add the value of any checked box to an intersection
table based on my last question to the list:
$art_id = mysql_insert_id();
What I'd like to end up with is something which for each value in
media_types[] create a New row in the intersection table (media_art)
However how can I make this:
$query = "INSERT INTO media_art (media_art_id,art_id, media_id)
VALUES ('','" . $art_id . "','" . $media_types[2]. "')";
repeat as many or few times as possible to account for the number of
checked boxes, such as
$art_id $media_types[5]
$art_id $media_types[9]
etc
I suspect it's something to do with the foreach but I'm stuck in
figuring it out.
Thanks in advance!
$media_types[] = ($_POST['media_types[]']);
Navigation:
[Reply to this message]
|