Minase Posted November 24, 2008 Share Posted November 24, 2008 hy there i have some querys entering data into a table and one column is autogenerated by sql server.it is an integrer with auto increment. table overview -ID -Name -Data my query insert information in Name and Data the ID is autogenerated,but after i enter Name and Data i need to get the ID of what was inserted. any typs? thanks Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted November 24, 2008 Share Posted November 24, 2008 well, you could always go back and re-query for the latest entry that matches the name & data you just entered $result= mysql_query("SELECT * FROM `table` WHERE `Name` = '$NameData' AND `Data` = '$DataData' ORDER BY `id` DESC") or die(mysql_error()); $row_result= mysql_fetch_array($result); echo $row_result['id']; Quote Link to comment Share on other sites More sharing options...
Minase Posted November 24, 2008 Author Share Posted November 24, 2008 so thats the only solution ? i was thinking on that but i wanted another solve. thanks for reply any other solve this have? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 24, 2008 Share Posted November 24, 2008 http://us3.php.net/mysql_insert_id Quote Link to comment Share on other sites More sharing options...
Minase Posted November 24, 2008 Author Share Posted November 24, 2008 exactly what i needed thank you 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.