Name
mysql_insert_id( )
Synopsis
mysql_insert_id([connection
])
This returns the identification number of the primary key of the last
record inserted using INSERT
for the current
connection, provided the column utilizes
AUTO_INCREMENT
and the value was not manually set.
Otherwise, 0 is returned.
... $sql_stmnt = "INSERT INTO workreq (date, clientid, description) VALUES(NOW( ), '1000', 'Network Problem')"; mysql_query($sql_stmnt); $wrid = mysql_insert_id( ); print "Work Request ID: $wrid \n"; ...
Here is the output of this script:
Work Request ID: 5755
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.