Codice PHP:
  mysql_connect("localhost""utente_mysql""password_mysql") or
      die(
"Connessione non riuscita: " mysql_error());
  
mysql_select_db("mio_db");
  
  
//cosi recuperi l'ultimo id inserito in una tabella qualsiasi
  
$query "SELECT campo_tabella FROM tabella ORDER BY campo_tabela DESC"//campo_tabella che contiene l'id
  
$result mysql_query($query) or die (mysql_error());
  
$row mysql_fetch_array($result);
  echo 
$row[0];

  
//cosi invece recuperi l' ultimo id appena inserito nella tabella
  
mysql_query("INSERT INTO mia_tabella (prodotto) VALUES ('kossu')");
  
printf ("L'ultimo recod inserito ha l'identificativo %d\n"mysql_insert_id());