Capital to capital distance

[insert_php]
$connection = mysql_connect(“localhost”,”mijnlieff_elbruz”,”c4MOyRfj”) or die (“Couldn’t connect to the database”);
$db = mysql_select_db(“mijnlieff_elbruz”) or die (“Couldn’t select database”);

if (isset($_POST[‘stad1’]))
{

$sql1 = “SELECT Capital, LocalName, LatDeg, LatSec, WindLa, LonDeg, LonSec, WindLo, Latitude, Longitude from capital where No={$_POST[‘stad1’]}”;
$sql_result1 = mysql_query($sql1,$connection) or die (“Couldn’t execute query”);
$capital1 = mysql_fetch_array($sql_result1);
$sql2 = “SELECT Capital,LocalName, LatDeg, LatSec, WindLa, LonDeg, LonSec, WindLo, Latitude, Longitude from capital where No={$_POST[‘stad2’]}”;
$sql_result2 = mysql_query($sql2,$connection) or die (“Couldn’t execute query”);
$capital2 = mysql_fetch_array($sql_result2);

$Aardconstante = 6367;
$test = atan2(-0.3, -1);
$test = asin(-0.3);

$x1 = $capital1[Longitude] * (pi() / 180);
$y1 = $capital1[Latitude] * (pi() / 180);

$x2 = $capital2[Longitude] * (pi() / 180);
$y2 = $capital2[Latitude] * (pi() / 180);

$GreatCircleDistance = round($Aardconstante * 2 * asin(sqrt(pow(sin(($y1-$y2)/2),2) + cos($y1)*cos($y2)*pow(sin(($x1-$x2)/2),2))),0);

echo “The Distance from $capital1[Capital] ($capital1[LocalName]) to $capital2[LocalName] ($capital2[Capital]) is $GreatCircleDistance km“;

}

else
{
$sql = “SELECT No, Capital from capital where length(Capital) > 0 order by Capital”;
$sql_result1 = mysql_query($sql,$connection) or die (“Couldn’t execute query”);
$sql_result2 = mysql_query($sql,$connection) or die (“Couldn’t execute query”);
$number = mysql_num_rows($sql_result1);

echo ”

Capital to Capital Distance

“;

echo “

“;

echo “

From Capital

“;
echo “

To Capital

“;

echo “

“;
}

[/insert_php]