Getting checkboxes as array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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[]']);

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux