Hi
If I have INSERT command and I have id column in my table (autoincrement, primary key)
When I di inser i want to find out what is the ID, that db assidned for the row. .
what command should i use?
Thanks!
geting last inserted row Id (MySQL)
Moderator: General Moderators
take a look at mysql_insert_id()
before I knew how to use insertid function (which was before I read your post) I just inserted all the information and queried
Code: Select all
$query = mysql_query("SELECT id FROM table WHERE something = '$somethingthatwasinsertedrightbeforethis'");
$row = mysql_fetch_assoc($query);
$id = $row['id'];