title: Populate dropdown box from array and display with php
body: <p>I am trying to populate a dropdown box with contents of the color array then display in a php file. Also display radio button selection on php file. I can not figure it out. I havent even started with the display of the array in the php file because I cant even populate the dropdown box. Any help would be much appreciated.</p>
  
  <h1>My HTML file</h1>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;?php
  $Color = array("Red", "Blue", "Green", "Cyan", "Magenta", "Yellow");
  $Food = array("Barbeque", "Chinese", "Japanese", "Thai", "Steak", "Vegan", "Mexican");
  ?&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;&lt;title&gt;Lab 08&lt;/title&gt;&lt;/head&gt; 
   &lt;body&gt; 
   &lt;h2&gt;Data Collection&lt;/h2&gt;&lt;p&gt; 
   &lt;form method="get" action="test.php"&gt;
   &lt;table&gt; 
   &lt;p&gt;Select your favorite color.&lt;/p&gt;
   &lt;select name=Color&gt; 
  
  
  &lt;?php
  
  foreach($Color as $col)
      {
      echo "&lt;option value=\"$col\"&gt;". $col ."&lt;/option&gt;\n";    
  }
  
  ?&gt;
  &lt;/select&gt;
   &lt;p&gt;Select your favorite type of food.&lt;/p&gt;
   &lt;input type="radio" name="Food" value="Barbeque"&gt;Barbeque&lt;br&gt;
   &lt;input type="radio" name="Food" value="Chinese"&gt;Chinese&lt;br&gt;
   &lt;input type="radio" name="Food" value="Japanese"&gt;Japanese&lt;br&gt;
   &lt;input type="radio" name="Food" value="Thai"&gt;Thai&lt;br&gt;
   &lt;input type="radio" name="Food" value="Steak"&gt;Steak&lt;br&gt;
   &lt;input type="radio" name="Food" value="Vegan"&gt;Vegan&lt;br&gt;
   &lt;input type="radio" name="Food" value="Mexican"&gt;Mexican&lt;br&gt;
   &lt;p&gt;&lt;/p&gt;
   &lt;tr&gt;&lt;td&gt;Enter your first name:&lt;/td&gt;&lt;td&gt;&lt;input name="First" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt; 
   &lt;tr&gt;&lt;td&gt;Enter your last name:&lt;/td&gt;&lt;td&gt;&lt;input name="Last" type="text" /&gt;&lt;/td&gt;&lt;/tr&gt; 
  
   &lt;tr&gt;&lt;td colspan="2" align="center"&gt;&lt;input type="submit" value ="Submit"/&gt;&lt;/td&gt;&lt;/tr&gt; 
   &lt;/table&gt; 
   &lt;/form&gt; 
   &lt;/body&gt; 
   &lt;/html&gt;
  </code></pre>
  
  <h1>My PHP file</h1>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;?php
      $First = (isset($_GET['First']) ? $_GET['First'] : null);
      $Last = (isset($_GET['Last']) ? $_GET['Last'] : null);
      $Color = (isset($_GET['Color']) ? $_GET['Color'] : null);
      $Food = (isset($_GET['Food']) ? $_GET['Food'] : null);
  ?&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;title&gt;Lab 08&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;?php
  
  
  if ($Color) {
  echo "&lt;p&gt;$Color&lt;/p&gt;";
      }
      else if (empty($Color)) {
      echo "&lt;p&gt;Please enter your favorite color.&lt;/p&gt;";
      }
  if ($Food)  {   
  echo "&lt;p&gt;$Food&lt;/p&gt;";
      }
      else if (empty($Food))  {
      echo "&lt;p&gt;Please enter your favorite food.&lt;/p&gt;";
      }
  if (!is_numeric($First) and (!empty($First)))   {
  echo "&lt;p&gt;$First&lt;/p&gt;";
      }
      else if (empty($First)) {
      echo "&lt;p&gt;Please enter first name.&lt;/p&gt;";
      }
      else if (is_numeric($First))    {
      echo "&lt;p&gt;First name must be letters.&lt;/p&gt;";
      }
  
  if (!is_numeric($Last) and (!empty($Last)))     {
  echo "&lt;p&gt;$Last&lt;/p&gt;";
      }
      else if (empty($Last))  {
      echo "&lt;p&gt;Please enter last name.&lt;/p&gt;";
      }
  </code></pre>