[PHP] Getting checkboxes as array

2005-06-09 Thread jack jackson
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

Re: [PHP] Getting checkboxes as array

2005-06-09 Thread Richard Davey
Hello jack, Friday, June 10, 2005, 2:16:06 AM, you wrote: jj $query = INSERT INTO media_art (media_art_id,art_id, media_id) jj VALUES ('',' . $art_id . ',' . $media_types[2]. '); jj repeat as many or few times as possible to account for the number of jj checked boxes, such as One

Re: [PHP] Getting checkboxes as array

2005-06-09 Thread Sebastian
Don't forget to mention that even if you don't select a checkbox it will still add a empty record to the db.. i know for sure the foreach loop will add a record even if a box is not check, so you have to check its actually set before you start inserting. Richard Davey wrote: Hello jack,

Re: [PHP] Getting checkboxes as array

2005-06-09 Thread jack jackson
Thank you Sebastian! Saved me some hell there!! On 6/9/05, Sebastian [EMAIL PROTECTED] wrote: Don't forget to mention that even if you don't select a checkbox it will still add a empty record to the db.. i know for sure the foreach loop will add a record even if a box is not check, so you have

Re: [PHP] Getting checkboxes as array

2005-06-09 Thread jack jackson
Whoops. I must be botching this syntax because this is printing ,,0,, as the query: All the first part of the query works and inserts records into the database, and it's when I try to get mysql_insert_id () that I seem to run into trouble. Ah. ave I not yet run the first query? The part of the

Re[2]: [PHP] Getting checkboxes as array

2005-06-09 Thread Richard Davey
Hello jack, Friday, June 10, 2005, 3:11:17 AM, you wrote: jj All the first part of the query works and inserts records into the jj database, and it's when I try to get mysql_insert_id () that I seem to jj run into trouble. Ah. ave I not yet run the first query? The part of jj the code that

Re: [PHP] Getting checkboxes as array

2005-06-09 Thread Sebastian
well, your trying to get the insert_id() without running the query first. so you have to add: mysql_query($query); before: $art_id = mysql_insert_id(); also, your foreach loop should be: foreach ($media_types as $type) (without the brackets []) i am assuming $media_types is an array