$query = "SELECT MAX(id) AS nfatt FROM fatture";
$res = mysql_query($query, $db);
$numero = mysql_fetch_assoc($res['nfatt']);
$numero++;