too long

I am very new to php and I am looking to create dynamic pages.

Basically If a person lands on www.example.co.uk/essex.php I would like to be able to add something like <h1>Company In <?php echo $row['County']; ?> so that it would show Company In Essex when Live and save time if I need to duplicate the page for another county or town.

So far I have setup a database in phpmyadmin

Picture of Table

My code so far to grab the table is;

$dbconnect = mysqli_connect("HOST", "USER", "PASSWORD", "DB");
if(mysqli_connect_errno()) {
    echo "Connection Failed:".mysqli_connect_error();
    exit;
}

$count_sql="SELECT * FROM areas";
$count_query=mysqli_query($dbconnect, $count_sql);
$count_rs=mysqli_fetch_assoc($count_query);

and then on www.example.co.uk/essex.php

<?php
do {
    echo $count_rs['County'];
} while ($count_rs=mysqli_fetch_assoc($count_query))

?>

But where I have gone wrong is it pulls all the data from the table for County where I only wish it to pull the county of Essex.

Please forgive me for explaining this badly.

UPDATE -

    $row = url2content();
extract($row);


function url2content($url = NULL){
if(is_null($url)){
if(isset($_SERVER["REQUEST_URI"]) && $_SERVER["REQUEST_URI"]){
$url = $_SERVER["REQUEST_URI"];
}elseif(isset($_SERVER["PATH_INFO"]) && $_SERVER["PATH_INFO"]){
$url = $_SERVER["PATH_INFO"];
}
if (substr($url,0,1) == '/'){
$url = substr($url,1);
}
}
if (DEBUG_MODE){
echo ('URL requested: "'.$url.'"<br>');
}



function get_towns($county){
    $query = sprintf("select townName from " . AREAS_TABLE . " where countyName = '%s'  order by rand() LIMIT 0,24" ,mysql_real_escape_string($county));
    $res = mysql_query($query);
    if(!$res){
        printf("Unable to query ".AREAS_TABLE." table: %s 
", mysql_error());
    }
    $html="";
    while($row = mysql_fetch_assoc($res)){
        $html.="<li>".stripslashes($row["townName"])."</li>
";
    }
    return $html;
}}

You have to use WHERE clause in your query in order to select a specific country from your db
SELECT * from table WHERE felid_country=$count_rs['County'];

You can use strpos() to match the County (eg.essex) with url $_SERVER['REQUEST_URI'] (eg.www.example.co.uk/essex.php) in your case. Just like this

<?php
do {
if(strpos($_SERVER['REQUEST_URI'],$count_rs['County'])!=false)
    echo $count_rs['County'];
} while ($count_rs=mysqli_fetch_assoc($count_query))