eludlow Posted May 21, 2008 Share Posted May 21, 2008 If I insert a row that has an auto_increment value (use it as row id field..) but then I want to use that id value immediately after the insert is complete (I am sending a mail containing, amongst other things, the latest id), what is the best way of getting the latest value? So for instance I have: mysql_query("INSERT INTO `table` VALUES ('', 'field two')"); And the first field in the above is the auto_increment field. I obviosuly don't know what the value of that is to now SELECT the row in question. Hope this makes sense! Many thanks, Ed Ludlow Link to comment https://forums.phpfreaks.com/topic/106589-solved-getting-auto_increment-value-of-latest-insert/ Share on other sites More sharing options...
eludlow Posted May 21, 2008 Author Share Posted May 21, 2008 Solved, mysql_insert_id() is my new best friend Ed Link to comment https://forums.phpfreaks.com/topic/106589-solved-getting-auto_increment-value-of-latest-insert/#findComment-546345 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.