$sql = "select max(id) as last_id from tabella";

no?