I need some help with a really simple problem. Using the following code for my geo site, if a user clicks on a state, I only want to correspoding state's cities to be displayed. I want to learn how to do this the right way but I get nothing but errors trying to nest the switch statements. I'm so close, I can taste it. Can anyone help?
<html>
<head>
<title>Site Title</title>
</head>
<body>
<table>
<tr>
<td valign="top">
<a href="<?=$SERVER['PHP_SELF']?>?state=Alabama">Alabama </a><br>
<a href="<?=$SERVER['PHP_SELF']?>?state=Alaska">Alaska</a><br>
<a href="<?=$_SERVER['PHP_SELF']?>?state=Arizona">Arizona</a><br>
</td>
<br>
<td valign="top">
<?php
// initialize the variables
$state = !empty($GET['state']) ? $state = $GET['state'] : $state = '';
$city = !empty($GET['city']) ? $city = $GET['city'] : $city = '';
// show content based on state selection
switch($state)
{
case "Alabama" :
print '<b>Alabama</b><br>';
include ('alCityLinks.php');
break;
case "Alaska" :
print '<b>Alaska</b><br>';
include ('akCityLinks.php');
break;
case "Arizona" :
print '<b>Arizona</b><br>';
include ('azCityLinks.php');
break;
default :
break;
}
// show content based on city selection
switch($city)
{
case "Auburn" :
print '<b>Auburn</b><br>';
break;
case "Bessemer" :
print '<b>Bessemer</b><br>';
break;
case "Birmingham" :
print '<b>Birmingham</b><br>';
break;
default :
break;
}
?>
</td>
</tr>
</table>
</body>
</html>
alCityLinks.php
<a href="?city=Auburn">Auburn</a><br>
<a href="?city=Bessemer">Bessemer</a><br>
<a href="?city=Birmingham">Birmingham</a><br>
?>