-
Feb 6th, 2012, 11:32 AM
#1
Thread Starter
Hyperactive Member
[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."
Base 2
Fcnncu"Nqxgu"Lguug##
-
Feb 6th, 2012, 11:56 AM
#2
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
-
Feb 6th, 2012, 11:58 AM
#3
Re: Get index of INSERT statement
Have a look at mysql_insert_id().
Edit: kfcSmitty slipped in before me.
-
Feb 6th, 2012, 12:10 PM
#4
Thread Starter
Hyperactive Member
Re: [RESOLVED] Get index of INSERT statement
Wow, I can't believe I've never come across that function. Thank you both!
Base 2
Fcnncu"Nqxgu"Lguug##
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|