php - Insert values into mysql with foreign key constraints -


i have 2 tables : 'spen_recipe' , 'spen_recipe_type' shown below

enter image description here

i want insert values spen_recipe , spen_recipe_type simultaneously based on pk , fk constraints.

please suggest me query.

this have tried:

insert spen_recipe  (`user_id`,`recipe_name`,`recipe_title`,`recipe_type`,`cooking_time`,`preparation_time`,`serving_to`,`recipe_desc`,`recipe_photo`,`created_at`,`modified_at`,`published_at`) values ('2','recipe2','title2',(select `recipe_type_id` spen_recipe_type),'20','30','4','desc1','image1','2016-11-05 11:21:43','2016-11-05 11:22:43','2016-11-05 11:21:43'); 

but need suggestion on how proceed after select recipe_type_id spen_recipe_type, cause both table has null values in columns, both empty.

should spen_recipe_type or spen_recipe first inserted?


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -