Why do you use "mysql"? mysql_ functions are now deprecated. You should use "mysqli" or PDO.mysqli supported same function like "mysql"
Example how to use mysqli
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"INSERT INTO Persons (FirstName,LastName,Age)
VALUES ('Glenn','Quagmire',33)");
// Print auto-generated id
echo "New record has id: " . **mysqli_insert_id($con)**;
mysqli_close($con);
?>
mysqli_insert_id($con) using this you can get last inserted id from database and using this id you can get a row.
but if you still need to use mysql then you may use this function mysql_insert_id(); you can get last inserted row id see example below
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb');
// it print last inserted id
printf("Last inserted record has id %d\n", mysql_insert_id());
?>
reffer to this http://php.net/manual/en/function.mysql-insert-id.php
and using that is also fetch last inserted row