For example, every user is going to have to have their contact information listed, so is every client. I've made a 'contact' table in addition to my 'user' table, and a column in my 'user' table points to the auto-incrementing index of the 'contact' table. That way, I don't have to have fields in both 'client' and 'user' which store the same type of data.
My problem is... on creating a new user, how would I add him as a contact, and retrieve 'contact.contact_id' as I do the insert? I could probably just do a search, and use the derived ID from the (hopefully) only contact with the same data I just wrote, but that seems a little... inefficient.
Would this work?
Code: Select all
$result = mysql_query("INSERT INTO contact (firstname, lastname, address, phone) VALUES ('Joe', 'Schmoe', '123 Street RD', '8885551212')");
$row = mysql_fetch_assoc($result);
echo $row['contact_id'];