spraypray12 Posted March 22, 2007 Share Posted March 22, 2007 I have a form, that gets sent to itself, and submits the data to a mysql database, then allows users to update their info, if it was wrong or they want to add something. Is their a way to get the id number (I have mysql table with id set to auto_incremet) from the submission that is initially sent so that it can be used in an update statement later. ( Where id= '".$id.''' or something) Thanks for any help! Quote Link to comment https://forums.phpfreaks.com/topic/43871-solved-get-id-from-query-just-sent/ Share on other sites More sharing options...
Kerblam Posted March 22, 2007 Share Posted March 22, 2007 As far as I know, the only way you could get the id is querying the database straight after. If possible, just use the information you just entered to find an exact match in the same table. Quote Link to comment https://forums.phpfreaks.com/topic/43871-solved-get-id-from-query-just-sent/#findComment-212956 Share on other sites More sharing options...
akitchin Posted March 22, 2007 Share Posted March 22, 2007 mysql_insert_id() will return the auto-increment ID that was inserted in the last query run using mysql_query(). alternatively, you can use MySQL's built-in LAST_INCREMENT_ID (check the documentation). Quote Link to comment https://forums.phpfreaks.com/topic/43871-solved-get-id-from-query-just-sent/#findComment-212958 Share on other sites More sharing options...
spraypray12 Posted March 22, 2007 Author Share Posted March 22, 2007 ok , i was thinking of doing that. I'll go ahead and see if that'll work. If any1 has any other suggestion feel free to post, else i'll marked this one solved in about a half hour. Quote Link to comment https://forums.phpfreaks.com/topic/43871-solved-get-id-from-query-just-sent/#findComment-212961 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.