Get last entered id

Hey,
If I add a new record to a table using mysql using php, howdo i get the id of the last entered record?

mysql_insert_id()

If you have the ID field auto_increment and then only you can use the mysql_insert_id.

Note: Because mysql_insert_id() acts on the last performed query, be sure to call mysql_insert_id() immediately after the query that generates the value.

Also there is a mysql function which gives you the most recently generated auto_increment id.

The value of the MySQL SQL function LAST_INSERT_ID() always contains the most recently generated AUTO_INCREMENT value, and is not reset between queries.

And if you don’t have the ID field auto_increment, then you should use some extra queries to get them like SELECT MAX(ID) FROM tblname.