mysql_insert_id()

Return the id generated the previous query

Example

<?php
mysql_connect(“localhost”, “root”, “phpcode”) or die( mysql_error());
mysql_select_db(“database_name”);
mysql_query(“INSERT INTO users (name) VALUES (‘PHP’)”);
echo();
mysql_close();
?>