[RESOLVED] Get index of INSERT statement
In php, I have a bit of code that runs
Code:
INSERT INTO tbl_name (stuff,things) VALUES ('23','45')
using the mysql_query($sqlquery) function.
The table has an additional column called "id" which is an auto incremental index.
Is there a way to get the index of this newly added row? I need the index so I can have something in an events table that basically says "Item 2 was added 2012/2/6."
Re: Get index of INSERT statement
Since you're using mysql_query, you can use mysql_insert_id.
http://php.net/manual/en/function.mysql-insert-id.php
Re: Get index of INSERT statement
Have a look at mysql_insert_id().
Edit: kfcSmitty slipped in before me.
Re: [RESOLVED] Get index of INSERT statement
Wow, I can't believe I've never come across that function. Thank you both!