title: PHP case switch statement with variable set in drop-down
body: <p>HI can someone tell me where I'm going wrong with this code. For some reason the variable <code>$BlogType;</code> isn't going through the Switch statement. This variable is set using a HTML drop-down and I have tested that its value changes accordingly with the user choice using the echo statement at the beginning of the code.</p>
  
  <p>But It doesn't seem to be going past the first 'break;' in the statement, as the echo statement in the Switch code below isn't printed:</p>
  
  <pre><code>echo "&lt;br /&gt; value in case " . $BlogType;
  echo "&lt;br /&gt; Blog " . $BlogType;  // OK, value changes with dropdown choice
  
  
  
  function getParameter($param, $defaultValue) {
          if (array_key_exists($param, $_GET)) {
          $value=$_GET[$param];
          return isSet($value)?$value:$defaultValue;
          }
          return $defaultValue;
      }
  
      $BlogType = getParameter("blog_type", "defaultValue");
      $byDate = getParameter("by_date", "defaultValue");
  
  
  $loopArr = array();
  switch ($BlogType) {
  
      case 0:
          $loopArr = $all_posts;                                                  
          break;
  
      case 1: 
          $loopArr = $music_matters-&gt;posts;
          echo "&lt;br /&gt; value in case " . $BlogType;
          break;
  
      case 2:
          $loopArr = $staff_student_news-&gt;posts;
          break;
  
      case 3:
          $loopArr = $kbs_news_events-&gt;posts;
          break;
  
      default: 
          $loopArr = array();
  }
  
  ?&gt;
  
  
  &lt;?php foreach ($loopArr as $post): {
      {    // code here
  </code></pre>