|
tekpr00 (IS/IT--Management) |
24 Oct 11 17:28 |
Hello All, Thanks for everyone that has been helping me with this PHP becuase I am just learning it. Lets face it I am not much of a coder.lol My next problem is that I am trying to use switch to print array however when I use the query from the drop down list to print the array nothing shows. Here is my result and code below. Thanks for your input as usual Result Office: (Pick one) (Query) Nothing shows CODE<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" 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=> "1. John Smith");
//create second array: $common = array(0=> "1. Fred Flintstone" , "2. Ann Jones");
//create third array: $north = array(0=> "1. Pebbles Flintstone", "2. Dino Flintstone");
//create fourth array: $south = array(0=> "1. Betty Rubble", "2. Barney Rubble", "3. Great Gazoo");
//creat associtive array: $offices = array ( 'Foyer' => $foyer, 'Common' => $common, 'North' => $north, 'South' => $south );
//print contents
//var_dump($offices); $offices=$_POST['offices']; switch ($offices){ case 'Foyer': print "<p>Employee in $foyer is</p>"; print "<p><i>{$offices['foyer'][0]}</i>.</p>"; break; case 'common': print "<p> Employee in $common are</p>"; print "<p><i>{$offices['Common'][0][1]}</i>.</p>"; break; print "<p> Employee in $north are</p>"; print "<p><i>{$offices['North'][0][1]}</i>.</p>"; break; print "<p> Employee in $south are</p>"; print "<p><i>{$offices['South'][0][1][2]}</i>.</p>"; break; }//end of switch
?> </form> </body> </html> |
|