aooga Posted November 25, 2008 Share Posted November 25, 2008 I have a table questions with questionID field set for autoincrement. When I create a new question $sql = INSERT INTO questions(...) $query = mysql_query($sql, $con) it works but I need to know in that very same script what the questionID is (that has been autoincremented.) How can I do that? Quote Link to comment https://forums.phpfreaks.com/topic/134237-how-do-i-find-out-right-what-autoincrement-has-set-my-field-as/ Share on other sites More sharing options...
flyhoney Posted November 25, 2008 Share Posted November 25, 2008 mysql_insert_id ? Quote Link to comment https://forums.phpfreaks.com/topic/134237-how-do-i-find-out-right-what-autoincrement-has-set-my-field-as/#findComment-698787 Share on other sites More sharing options...
Maq Posted November 25, 2008 Share Posted November 25, 2008 Right after you insert you could select from that table and ORDER BY id DESC. Quote Link to comment https://forums.phpfreaks.com/topic/134237-how-do-i-find-out-right-what-autoincrement-has-set-my-field-as/#findComment-698790 Share on other sites More sharing options...
aooga Posted November 25, 2008 Author Share Posted November 25, 2008 perfect, thanks a million! Quote Link to comment https://forums.phpfreaks.com/topic/134237-how-do-i-find-out-right-what-autoincrement-has-set-my-field-as/#findComment-698794 Share on other sites More sharing options...
Maq Posted November 25, 2008 Share Posted November 25, 2008 mysql_insert_id ? Nice, didn't even know about this function. Quote Link to comment https://forums.phpfreaks.com/topic/134237-how-do-i-find-out-right-what-autoincrement-has-set-my-field-as/#findComment-698801 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.