$datos = mysql_query("select id from correspondencia order by id desc"); $resultado = mysql_fetch_array($datos) $last = $resultado[0];