jonniejoejonson Posted December 18, 2007 Share Posted December 18, 2007 I want to insert 'message' details into a table that has an autoincrement int. This integer servers as the unique index for the message. However I need to select this index number as it is inserted so that I can store it in another table... do you know how to do this... $sql= "INSERT INTO messages (date,subject,message) VALUES (NOW(),'$subject','$message') I then want to select the 'messageindex' for this inserted row"; (messageindex is the autoincrement integer) thanks to any responders. Link to comment https://forums.phpfreaks.com/topic/82228-solved-php-get-the-auto-incement-value-at-the-time-of-insert/ Share on other sites More sharing options...
p2grace Posted December 18, 2007 Share Posted December 18, 2007 $id = mysql_insert_id(); Link to comment https://forums.phpfreaks.com/topic/82228-solved-php-get-the-auto-incement-value-at-the-time-of-insert/#findComment-417885 Share on other sites More sharing options...
The Little Guy Posted December 18, 2007 Share Posted December 18, 2007 $id = mysql_insert_id(); OMG that will be very helpful for me! Link to comment https://forums.phpfreaks.com/topic/82228-solved-php-get-the-auto-incement-value-at-the-time-of-insert/#findComment-417887 Share on other sites More sharing options...
jonniejoejonson Posted December 18, 2007 Author Share Posted December 18, 2007 Thanks alot p2grace, that works perfect. Link to comment https://forums.phpfreaks.com/topic/82228-solved-php-get-the-auto-incement-value-at-the-time-of-insert/#findComment-417894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.