if i have a table like this
tbl_attributes
---------------
id_attrib (auto incremented, primary key)
col1
col2
and another table
tbl_weight
--------------
id_attrib *(not primary key)*
field
when it comes time to insert values into the table tbl_attributes as i insert values for col1 and col2 the id_attrib is auto incremented. how can i insert that same auto incremented value of id_attribute into the field id_attrib in the table tbl_weight . the reason im doing this is because
i am looking for specific values being entered into tbl_attributes and once the value im looking for has been inserted into tbl_attributes then more information related to that will be entered into tbl_weight.
otherwise if i combined the tables which would look like
tbl_attributes
----------------
id_attrib
col1
col2
field (from tbl_weight table)
the field column would contain alot of empty data and would only contain data when something is met and i dont want to do it like that.
so maybe getting the current auto_increment to be used for tbl_attributes and insert that value. I was thinking of using innodb format but i am new to that world and things might get messed up.
Manual: mysql_insert_id()
Now you can use that ID for another INSERT query (
tbl_weight).Example:
Note: Don’t forget to check
mysql_query()result.