$result = mysql_db_query ( "$database", "SELECT * FROM gruppi_foto ORDER BY POS");
while ($valori = mysql_fetch_array ($result)){
$idgruppo=$valori["ID"];
$nomegruppo=$valori["TESTOEN"];
?>
$result2 = mysql_db_query ( "$database", "SELECT * FROM foto WHERE IDGR='$idgruppo' ORDER BY POS");
while ($valori2 = mysql_fetch_array ($result2)){
$idfoto=$valori2["ID"];
$didafoto=$valori2["DIDAEN"];
?>
}?>
}?>