Fearpig Posted April 30, 2007 Share Posted April 30, 2007 Hi guys, could someone have a look at this problem for me and suggest a solution or tutorial for me!! I've got three tables... Event, Person, Attendee and they have the following fields: Event Event_ID Event_Name Event_Date Duration Person Person_ID Name Telephone Mobile EMail Attendee Line_ID Event_ID Person_ID Payment_Recieved At the moment I have written a page that displays an event and the people who are attending. I am trying to set up a page that adds extra people to the event. To do this I need to populate the Attendee and Person tables with one more record per person added. The problem is that I have to populate the Attendee table with the Person_ID which isn't generated until I populate the person table (autogenerated integer field)! Can anyone suggest a solution? It'd be appreciated as Ireally can't think where to even get started on this one! Link to comment https://forums.phpfreaks.com/topic/49302-sql-insert-to-several-tables/ Share on other sites More sharing options...
monk.e.boy Posted April 30, 2007 Share Posted April 30, 2007 Add a person, get the auto incremented ID (http://php.net/mysql_insert_id) Now create the second update SQL statement to insert into the attendee table using the above ID. You may wish to google MySQL transactions (this will help id you successfully insert a person, but the second SQL raises an error) monk.e.boy Link to comment https://forums.phpfreaks.com/topic/49302-sql-insert-to-several-tables/#findComment-241601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.