il fatto è che questo
onClick="window.open('file.php?id=$dati[id]');
è già dentro tag php.