Clinton Posted February 12, 2009 Share Posted February 12, 2009 Ok, I use this code to insert a record into the db... $result = mysql_query("INSERT INTO ply (did, rn, cltr, eid, jid, cdate) VALUES ('$did', '$rn', '$cltr', '$eid', '$jid', '$cdate')"); Now, when this inserts it does an automatic auto-increment on an 'id' column that is not listed. Is there a way that I can turn right back around after this gets inserted and get the corresponding id number? Quote Link to comment Share on other sites More sharing options...
mike12255 Posted February 12, 2009 Share Posted February 12, 2009 you could try this: $newitems = mysql_query ("SELECT * FROM ply ORDER BY id DESC LIMIT 1") Might have to be asc but im pretty sure its desc btw no promises on that im not the best at mysql Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 12, 2009 Share Posted February 12, 2009 http://us3.php.net/mysql_insert_id Quote Link to comment Share on other sites More sharing options...
printf Posted February 12, 2009 Share Posted February 12, 2009 Something like... mysql_query(INSERT query here...); echo mysql_insert_id(); Quote Link to comment Share on other sites More sharing options...
mike12255 Posted February 12, 2009 Share Posted February 12, 2009 hey thanks PFMaBiSmAd i've never heard of that, im sure it'll help me too! Quote Link to comment Share on other sites More sharing options...
Clinton Posted February 12, 2009 Author Share Posted February 12, 2009 mysql_insert_id() <-- didn't know that existed. Thanks for all the replies and ideas. Quote Link to comment 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.