Forum Moderators: open
Using PHP and MySQL, say I have an html form with a couple single line text fields that enter data into a table (date, title, link, story). Then say I have a series of check boxes that are labled with different categories: (news, reviews, articles, products, etc). They associate with another table.
I have 3 tables in my db: stories, categories, story_category
stories table has: (story_id, date, title, link, etc)
categories table has: (category_id, name)
story_category table has: (story_category_id, story_id, category_id)
Even though I'm not 100% yet on making this work, this thread about categories was very helpful: [webmasterworld.com...]
I'll figure that part out, but what I'm lost on is how to use one html form with different elements (text field, checkbox) to insert data into 2 different tables. I know its all in the query statement, but since this method of categories uses the story_id multiple times in the story_category table if there is more than one category, incorporating this with a check box is throwing me off.
I know how to make a form and have the data inserted into a single table in a database. Its the checkboxes and second table that are throwing me off. Any suggestions are very much appreciated. Thanks.
so to check against a checkbox:
if(isset($_POST['chbox']) && $_POST['chbox'] == "on") $chbox = 1;
else $chbox = 0;
Sorry for putting php into mysql forum ;)
And mysql_insert_id will do just fine.
Regards
Michal