Hello All,
My array is only printing one element instead of mutiple elements where appropriate, please help identify error
My array is only printing one element instead of mutiple elements where appropriate, please help identify error
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title> Employee Office Array </title>
</head>
<body>
<form action="emp_office_array.php" method="post">
<p>Office:
<select name ="office">
<option value="">Pick One</option>
<option value="foyer">Foyer</option>
<option value="common">Common</option>
<option value="north">North</option>
<option value="south">South</option>
</select></p>
<input type="submit" name="submit"
value="Query" />
<?php
//Create first array:
$foyer = array(0=> ' John Smith');
//create second array:
$common = array(0=> 'Fred Flintstone' , 'Ann Jones');
//create third array:
$north = array(0=> 'Pebbles Flintstone', ' Dino Flintstone');
//create fourth array:
$south = array(0=> ' Betty Rubble', ' Barney Rubble', 'Great Gazoo');
//creat associtive array:
$offices = array (
'Foyer' => $foyer,
'Common' => $common,
'North' => $north,
'South' => $south
);
//print contents
//var_dump($offices);
//$offices_switch=$_POST['offices'];
switch($_POST['office']){
case 'foyer':
print "<p>Employee in Foyer is<i>{$offices['Foyer'][0]}</i>.</p>";
break;
case 'common':
print "<p> Employee in Common are<i>{$offices['Common'][0]}</i>.</p>";
break;
case 'north':
print "<p> Employee in North are<i>{$offices['North'][0]}</i>.</p>";
break;
case 'south':
print "<p> Employee in South are<i>{$offices['South'][0]}</i>.</p>";
break;
}//end of switch
?>
</form>
</body>
</html>