fmsf
fmsf

Reputation: 37137

PHP&MySQL: Is it possible after running mysql_query with an insert to get the ID of the new row?

Is there a straightforward way to run mysql_query with an insert and get the ID of the new row, for example in the return? Or will I have to do another query with select to check it?

Upvotes: 1

Views: 163

Answers (3)

soulmerge
soulmerge

Reputation: 75704

Try mysql_insert _id()

Upvotes: 2

Noah Goodrich
Noah Goodrich

Reputation: 25263

Simply call mysql_insert_id after running mysql_query and you will get the ID.

Upvotes: 2

railsmail
railsmail

Reputation:

mysql_insert_id()

or

select last_insert_id()

Upvotes: 7

Related Questions