Data Validation, dynamically generated fields (select for example)

As long as you do not allow anyone to edit/add new countries to your list I don’t see any problems. The content of $ctry_code_sel is only controlled/modified by you.

If, on the other hand, you allow users to modify any data you use to generate the select, you should use escaping methods directly during generation, not after the HTML for the select is finished.

And as you are using a country list, maybe this could also be helpful for you: https://github.com/umpirsky/country-list/