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
how to insert values in mysql table using php
Moderator: General Moderators
-
srichandar
- Forum Newbie
- Posts: 6
- Joined: Thu Apr 02, 2009 9:36 am
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: how to insert values in mysql table using php
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().
However, the solution is to use mysql_insert_id().