When you use a auto increment primary key id field, you usually have no track of what is the current inserted id in the auto increment field. But there are situation where you need to know the last increamented id.
You can simply use mysql_insert_id()
<?php
mysql_query("insert into mytable (v_name) values ('kusal')");
$last_id = mysql_insert_id();
echo $last_id;
?>