mysql_insert_id ([link_id])
This function returns the value that was automatically assigned to an AUTO_INCREMENT column in the previous INSERT query for the default or specified (link_id) MySQL connection. If no AUTO_INCREMENT value was assigned in the previous query, 0 is returned instead.