I'm creating an application where I have 2 users. An admin and patient so each account has 2 users (where the admin adds medication and other to do list for the patient to do).
Both admin and patient can log in to the same account this is why acc_id is the common link between them.
account_info(acc_id(pk, auto inc), p_username, a_username,password)
These will be entered on one page.
After that the user goes to enter the patient information, where he enters Patient information.
patient_info ( p_username (pk), acc_id, p_fname,....)
The admin_info
table has almost the same table as patient_info
How do I write the insert code in a way where acc_id and p_username are selected from account_info table and the rest of the information is just inserted into the table patient_info.
My code so far:
$sql = "INSERT INTO patient_info(p_username, acc_id, p_fname, p_lname,
p_gender, p_condition,
p_birthdate, p_emergencycontact)
SELECT p_username, acc_id
FROM account_info
VALUES(:p_fname, :p_lname, :p_gender, :p_condition, :p_birthdate,
:p_emergencycontact)";
I am new to php. I understand the logic but I don't know how to write it.