When i add a new from my custom CMS, i need to add some diferent info about this post at 2 different tables.
So the first table is DATA and the Second is SEO.
When I press on PUBLISH button at my cms , i add some data at DATA table with xx id, also i add some data at SEO table , but i need that the data inserted at SEO table have same ID with the data added at DATA table.
I have looked around but i haven't found what i wanted.
Please if some one know how to do that,please answer to this post.
It's tricky without any more information but I'd guess you're looking for mysql_insert_id()
$sql = 'INSERT INTO table (col) VALUES (1)';
mysql_query($sql);
$inserted_id = mysql_insert_id();
// Run your next query
assuming you are using msysql and the first table has autoincrement id, then you can use
$id = mysql_insert_id()
to get the id after the first insert, then use that id in the 2nd insert
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.