chelnov63 Posted July 30, 2008 Share Posted July 30, 2008 hi i havent worked to much with relationships between tables, so this maybe a kind of a newbie question: I have two tables, one is a list of activities, the other a list of participants. I want to insert one record in the activities table and then using its identity column as foreign key, I want to insert two or more records into the participants table. My problem is that I have no idea what foreign key to use when inserting names into the participants table. How can I get hold of the row's key or identity column, immediately after inserting a row into the activity table? Link to comment https://forums.phpfreaks.com/topic/117318-inserting-record-into-primary-table-and-foreign-key-table/ Share on other sites More sharing options...
GingerRobot Posted July 30, 2008 Share Posted July 30, 2008 Use the mysql_insert_id() function. Link to comment https://forums.phpfreaks.com/topic/117318-inserting-record-into-primary-table-and-foreign-key-table/#findComment-603435 Share on other sites More sharing options...
chelnov63 Posted July 30, 2008 Author Share Posted July 30, 2008 awesome!!! thanks mate!! Link to comment https://forums.phpfreaks.com/topic/117318-inserting-record-into-primary-table-and-foreign-key-table/#findComment-603436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.