PHP code.. To get user_ID from one table to another, and insert automatically into to that other table (after do the PK FK) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

PHP code.. To get user_ID from one table to another, and insert automatically into to that other table (after do the PK FK)

First of all I'm a noob beginner so I'm sorry for my stupid question.. I have 2 table in DB ,userlogin (user_ID as PK) and appointment (user_ID as FK) How to automatically insert the user ID PK to user_ID FK. After the user register (save data in userlogin table) then the user can login and submit appointment (data save in appointment table) 1:M relationship.

2nd Nov 2019, 10:18 AM
syasha izrina
syasha izrina - avatar
3 Answers
+ 3
Write the logic which will first insert data in first table and return the generated unique Id. Now insert that Id in second table.
2nd Nov 2019, 1:36 PM
A͢J
A͢J - avatar
0
Thanks
2nd Nov 2019, 3:05 PM
syasha izrina
syasha izrina - avatar
0
I'm using mysql, can u teach me how to do that in php. user_id : auto increment
4th Nov 2019, 12:08 PM
syasha izrina
syasha izrina - avatar