HTML
<label for="wall_category">Wall Category:</label>
<input type="checkbox" name="wallpaper"> Wallpaper
<input type="checkbox" name="photography"> Photography
PHP
//obtains last insert id
$wallId = mysql_insert_id();
echo $wallId;
I have categories
table in my database in which the following data is stored:
category_id category_name
1 Wallpaper
2 Photography
and I have another table called wall_categories
in which:
wall_id (P, F) category_id (P, F)
After getting the wall_id from last_insert_id, I want to check what category among the two is checked. For example, Wallpaper
checkbox is checked, since the category_id
is 1
, I want to store that category_id
along with whatever the wall_id
will be to my wall_categories
table. So my table will become (lets say wall_id
is 16
)
wall_id (P, F) category_id (P, F)
16 1
And one last thing to add since Categories are checkboxes, when both are selected, I want to add both to my wall_categories
table so my wall_categories
table would become:
wall_id (P, F) category_id (P, F)
16 1
16 2
I was trying some workarounds, but I'm still a rookie in PHP. Would like to ask your help on how to do this. Thanks! (The script will just be used internally.)