Hi! How to populate a table with FK from a parent table, with mysql and PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi! How to populate a table with FK from a parent table, with mysql and PHP?

Hi, I an building a simple website in PHP and MySQL pdo database. I have created user registration form, login and I want to create a dashboard that user have to update some datails. I have 2 tables in my database, first to keep user-registration data and second table to keep other detalis that user have to upload in dashboard of website. I have linked 2 tables with foreign key. My question is how to insert values in second table and populate foreign key column with values of first table in this case user_id in first table to relate with FK in second table? (I have implement session) Thanks!

23rd Nov 2020, 1:41 AM
Imelda
2 Answers
+ 1
Thank you!
26th Nov 2020, 8:04 PM
Imelda
0
Select user_id from firstTable where ... Result of this in php variable and then you can Isert into secondTable Values...
26th Nov 2020, 8:01 PM
Václav Dostál
Václav Dostál - avatar