Page 1 of 1

how to insert values in mysql table using php

Posted: Wed Apr 08, 2009 4:55 am
by srichandar
Hi all,
I want to insert the values from php registration form in to mysql db using the foreign key,

Table structure,
Table1:
userid primary key autoincrement,
username
emailid

Table 2:
id
Phone number
Address
Fax
Foreign key(id) reference Table1(userid)

for inserting values into table2 i have to use the Table1's primarykey, Question is how to get the table1's primary key and insert into table2.

thanks in advance,
sridhar

Re: how to insert values in mysql table using php

Posted: Wed Apr 08, 2009 5:15 am
by jayshields
Why have you split up those tables, and why is the relationship one-to-many going from user details to contact details? Are you going to assign multiple sets of contact details to each user?

However, the solution is to use mysql_insert_id().