Wednesday, June 15, 2016

php - Get ID of row from database where the data was inserted

I'm running a MySQL INSERT query where I insert some data into the database.
Each row has a unique ID generated each time a new entry is added. I'd like to get this ID straight after I insert the data.



PHP Code:



$addGiveawayToDb = mysql_query("INSERT INTO $table(orientation, title, color) 

VALUES ('$orientation', '$title', '$color')")
or die(mysql_error());
//Here I need to get the row id of the above data...


Thanks!

No comments:

Post a Comment