dan400007 Posted November 16, 2006 Share Posted November 16, 2006 Hi, I want to insert a record into a mysql table and then have it return ID for the record just entered. Example of what I want to happen is below:table:ID mediumint( 8 ) Auto-increment unsigned not nullcol1 textcol2 textINSERT INTO table (col1, col2) VALUES ('This is col1', 'This is col2');When the insert occurs I want mysql to return the ID for the record it just inserted, is this possible?Thanks, Dan Link to comment https://forums.phpfreaks.com/topic/27521-return-a-mysql-value-on-insert/ Share on other sites More sharing options...
trq Posted November 16, 2006 Share Posted November 16, 2006 Funnilly enough there is a function made especially for that. [url=http://php.net/mysql_insert_id]mysql_insert_id[/url]. Link to comment https://forums.phpfreaks.com/topic/27521-return-a-mysql-value-on-insert/#findComment-125841 Share on other sites More sharing options...
dan400007 Posted November 16, 2006 Author Share Posted November 16, 2006 Brilliant!! :DThanks for such a quick reply.Dan. Link to comment https://forums.phpfreaks.com/topic/27521-return-a-mysql-value-on-insert/#findComment-125844 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.