<?php

    include_once "library.php";


	$cxn = start_code( false, true );


    $display_country = val( $_GET, "displaycountry");
    
    
    if ($display_country == "")
        $display_country = get_country_from_subdomain( $cxn );


	page_header( "City/region links", $cxn, false, true );


	$query = "SELECT display_name, prefix, flag_file_name, php_file_name FROM ".common_data_database_name.".country WHERE display_name = '".$display_country."'";

    $result = run_query( $query, $cxn );

    $the = "";

    if (query_num_rows($result) > 0)
    {
	    $data = get_row( $result );	
	    
	    $the = $data['prefix'];
	    
	    if ($the != "")
	        $the = "the ";
    }

	if ($the != "")
        echo black( "<br><br><br>We have city/region entry pages to the site for all residents of the following cities/regions of the ".$display_country."<br><br><br" );
    else
        echo black( "<br><br><br>We have city/region entry pages to the site for all residents of the following cities/regions of ".$display_country."<br><br><br" );


	$query = "SELECT * FROM ".common_data_database_name.".full_list_cities_regions WHERE country = '".$display_country."' ORDER BY city_region_etc";
	

    $result = run_query( $query, $cxn );

    $last_heading_letter = "";
    
	for ($i=0; $i < query_num_rows( $result ); $i++)
	{
    	$data = get_row( $result );

        if ($data['city_region_etc'] != "")
        {
            if ($last_heading_letter != substr( $data['city_region_etc'], 0, 1))
            {
                echo "<br>";
                
                $last_heading_letter = strtoupper( substr( $data['city_region_etc'], 0, 1) );
                
                echo black( $last_heading_letter."<br>" );
            }
        }
        
        echo "<a class='glink' href='/city/".$data['city_region_etc'].".php'>".$data['city_region_etc']."</a><br>";
    }


?>