use mysql_insert_id()
i think its what you are looking for
example
create table a (id_num mediumint unsigned auto_increment not null,
something varchar(10),
primary key (id_num));
then your php code:
$query = "INSERT INTO a (something) VALUES ('$my_val')";
$result = @($query);
$updated_id_num = mysql_insert_id();
This will provide the incremented id_num for the row in table a that was just inserted.