functions – Dynamic dropdown from database table

I need a little help:
I want to create a drop-down populated by mysql database table with two options:
Select option 1 (regions)
Select option 2 (schools)

Where in option 2 appears populated according to option 1. (ie. tot Schools in region 1) and the selection should be stored in User profile.

I know that we can achieve this with functions.php
Something like this:

function loadSchools(){
        global $wpdb;
        return $wpdb->get_results( "SELECT MIN(school_id) AS id, region FROM region GROUP BY region" );


Someone already did something similar?

Thank you