vikaspa Posted April 4, 2008 Share Posted April 4, 2008 Dear Please help me I am inserting a records in a table I want to know the id for the row inserted which is auto generated How can i get it Please please help Link to comment https://forums.phpfreaks.com/topic/99498-get-id-for-row-inserted/ Share on other sites More sharing options...
zenag Posted April 4, 2008 Share Posted April 4, 2008 $sql=mysql_query("insert into ....); echo mysql_insert_id(); gives the id of the row inserted. Link to comment https://forums.phpfreaks.com/topic/99498-get-id-for-row-inserted/#findComment-509055 Share on other sites More sharing options...
jana Posted April 4, 2008 Share Posted April 4, 2008 as a mysql query u can use select last_insert_id(); as in php u can u as zenag said Link to comment https://forums.phpfreaks.com/topic/99498-get-id-for-row-inserted/#findComment-509091 Share on other sites More sharing options...
gluck Posted April 4, 2008 Share Posted April 4, 2008 as a mysql query u can use select last_insert_id(); as in php u can u as zenag said Make sure you get id right after the insert else if someone else fires an insert before you did the select you might get wrong results. Link to comment https://forums.phpfreaks.com/topic/99498-get-id-for-row-inserted/#findComment-509500 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.