Use the mysql_insert_id() function...
$result = mysql_query("INSERT INTO your_table (name) VALUES ('John')");
$id_number = mysql_insert_id($LINK_ID);
Where $LINK_ID is what's returned from mysql_connect...
You can also find the number in your query. After the first insert above, to insert something into another table using the same id, you do this:
$result2 = mysql_query("INSERT INTO table2 (id,address) VALUES (LAST_INSERT_ID(),'123 Buffalo Street')");
Hope that helps...
---John Holmes...