title: PHP radio buttons, multidimensional array
body: <p>Alright, I don't have any clue what I'm doing. I have set up my multidimensional array correctly I think. The problem I'm having is when you select the radio button, the results need to come out.  I'm a complete noob at this PHP stuff.... </p>
  
  <p>Here is my radio buttons html:</p>
  
  <pre><code>&lt;h2&gt;List animals by &lt;/h2&gt;
  &lt;ul&gt;
  &lt;li&gt;Habitat: (This selection doesn't work in the demonstration)
  &lt;form action="" method="post"&gt;
  &lt;input type="radio" name="Habitat" value="Forest"&gt; Forest
  &lt;input type="radio" name="Habitat" value="Farm"&gt; Farm
  &lt;input type="radio" name="Habitat" value="Desert"&gt; Desert
  &lt;input type="submit" name="submit" value="List Animals"&gt;
  &lt;/form&gt;
  &lt;li&gt;
  Food:
  &lt;form action="" method="post"&gt;
  &lt;input type="radio" name="Food" value="Meat" ?prefix=Meat&gt; Meat
  &lt;input type="radio" name="Food" value="Grass" ?prefix=Grass&gt; Grass
  &lt;input type="radio" name="Food" value="Mixed" ?prefix=Mixed&gt; Mixed
  &lt;input type="submit" name="submit" value="List Animals"&gt;
  &lt;/form&gt;
  &lt;/ul&gt;
  &lt;hr&gt;
  </code></pre>
  
  <p>And here is my php..... I am a complete noob at this. This is my first "assignment". I'm having too much trouble over this. Some pointers that would steer me the right way would be wonderful.</p>
  
  <pre><code>&lt;?php
  
  if (isset($_post['submit'])){
  if (isset($_post['radio']))
  
  
  
  $animalList = array ();
      $animalList[0] = array ();
          $animalList[0] ['Animal'] = "Bear";
          $animalList[0] ['Habitat'] = "Forest";
          $animalList[0] ['Food'] = "Meat";
      $animalList[1] = array();
          $animalList[1] ['Animal'] = "Deer";
          $animalList[1] ['Habitat'] = "Forest";
          $animalList[1] ['Food'] = "Grass";
      $animalList[2] = array();
          $animalList[2] ['Animal'] = "Pig";
          $animalList[2] ['Habitat'] = "Farm";
          $animalList[2] ['Food'] = "Mixed";
      $animalList[3] = array();
          $animalList[3] ['Animal'] = "Cow";
          $animalList[3] ['Habitat'] = "Farm";
          $animalList[3] ['Food'] = "Grass";
      $animalList[4] = array();
          $animalList[4] ['Animal'] = "Sheep";
          $animalList[4] ['Habitat'] = "Farm";
          $animalList[4] ['Food'] = "Grass";
      $animalList[5] = array();
          $animalList[5] ['Animal'] = "Camal";
          $animalList[5] ['Habitat'] = "Desert";
          $animalList[5] ['Food'] = "Grass";
      $animalList[6] = array();
          $animalList[6] ['Animal'] = "Scorpion";
          $animalList[6] ['Habitat'] = "Desert";
          $animalList[6] ['Food'] = "Meat";
  
  
  
  function showAnimals($prefix_requested){
  
      global $animalList;
  
      $tbl = "&lt;table border=1&gt;";
      $tbl = $tbl."&lt;tr&gt;&lt;th&gt;Animal&lt;/th&gt;&lt;th&gt;Habitat&lt;/th&gt;&lt;th&gt;Food&lt;/th&gt;&lt;/tr&gt;";
  
      foreach ($animalList as $animal){
  
          if ($animal['Animal'] == $prefix_requested){
  
      $tbl .= "&lt;tr&gt;&lt;td&gt;{$animal['Animal']} 
               {$animal['Habitat']}&lt;/td&gt;&lt;td&gt;           
               {$animal['Food']}&lt;/td&gt;&lt;/tr&gt;";
          }
      }
  
      $tbl .="&lt;/table&gt;";
      echo $tbl;
      }
  
  
      echo "".$_post['radio'];
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>A little bit long, I know... if someone could steer me the right way I would be so grateful!!!!!</p>