Jump to content

write in 2 table


nec9716

Recommended Posts

yes. after you insert a record into table 1, you can use $insert_id = mysql_insert_id() to get the id for that record. then when you add the associated record to table 2, you include the $insert_id of record 1

 

table_1

id

item_name

 

table_2

id

table1_id <-- use the id of table_1 here to associate this record with the record in table_1

item_color

 

this is a 'relation' and is the basis for 'relational databases' like MySQL

 

http://www.databasejournal.com/sqletc/article.php/1469521

 

Link to comment
https://forums.phpfreaks.com/topic/97806-write-in-2-table/#findComment-500400
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.