GingerRobot Posted July 6, 2006 Share Posted July 6, 2006 Ok, i am inserting a row into a mysql table and the field `id` is automatically given a number as it is set to auto-increment.After performing the insert, is there any way to find out what number was actually put into the id field?I hope that makes sense.Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/13829-auto_increment-finding-value-assignedsolved/ Share on other sites More sharing options...
Chips Posted July 6, 2006 Share Posted July 6, 2006 with mysql you can use the insert_id function, which can be found here - in the mysql documentation on php.net.http://uk.php.net/manual/en/function.mysql-insert-id.phpIf you have any trouble with it working, then I am sure others will be able to help - just beware that it will return the [i]last insert id[/i], so if you are running two inserts (info into two tables) it will return the id for the second table, NOT the first. Link to comment https://forums.phpfreaks.com/topic/13829-auto_increment-finding-value-assignedsolved/#findComment-53764 Share on other sites More sharing options...
wildteen88 Posted July 6, 2006 Share Posted July 6, 2006 You'll want to use a function called [url=http://uk.php.net/manual/en/function.mysql-insert-id.php]mysql_insert_id[/url] Link to comment https://forums.phpfreaks.com/topic/13829-auto_increment-finding-value-assignedsolved/#findComment-53769 Share on other sites More sharing options...
GingerRobot Posted July 6, 2006 Author Share Posted July 6, 2006 Thanks very much to both of you, that is exactly what i want.Thanks again. Link to comment https://forums.phpfreaks.com/topic/13829-auto_increment-finding-value-assignedsolved/#findComment-53771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.