Distance between cities
Posted: Sun Nov 13, 2011 6:46 pm
Having trouble with a distance program i am working on. The user has two choices(radio buttons) dallas or chicago. They tthen choose a destination from a selection list. Output should be the distance, time it takes to drive and walk those distances. My output page is only displaying the heaings and titles. Can someone please tell me what i am doing wrong..
here's what i have:
here's what i have:
Code: Select all
<?php
$cities =array ('Dallas' => 803, 'Toronto' => 435, 'Boston' => 848, 'Nashville' => 406, 'Las Vegas' => 1526, 'San Francisco' => 1835,
'Washington, DC' => 595, 'Miami' => 1189, 'Pittsburgh' => 409);
$cities2 = array ('Chicago' => 803, 'Toronto' => 1202, 'Boston' => 1548, 'Nashville' => 615, 'Las Vegas' => 1073, 'San Francisco' => 1483,
'Washington, DC' => 1181, 'Miami' => 1107, 'Pittsburgh' => 1068);
if (isset($_POST['dal']) && isset($cities['destination'])) {
$distance = $cities['destination'];
if (isset($_POST['chi']) && isset($cities['destination'])){
$distance = $cities2['destination'];
$time = round(($distance / 60), 2);
$walktime = round(($distance / 5), 2);
print "The distance between Chicago and <i>['destination']</i> is $distance miles.";
print "<br> Driving at 60 Miles per hr. it would take $time hrs.";
print "<br> Walking at 5 Miles per hr. it would take $walktime hrs.";}
else {
print "Please select a Starting city and a Destination.";}}
?>