I remember reading somewhere about ...
Creating code that does what you want, when and where you want it to be, is not a matter of reading somewhere about something, it is a matter of making your code do what you want and when your code does not do what you want it is a matter of troubleshooting what it is doing. Did you look at and read the code that is responsible for producing the output in question.
The for(){} loop that is producing the menu contains the entire code for the <select>...</select> menu inside of it, so of course you will get a complete menu for each pass through the for(){} loop.
Wouldn't the solution be to output just the <option>...</option> choices inside of the for(){} loop?