May 2005
Intermediate to advanced
352 pages
14h 39m
English
mysql_insert_id( )
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
Read now
Unlock full access