foreach messo così non ti serve a nulla, while scorre già tutti i risultati