title: PHP Switch Case - keeping option selected
body: <p>I tried multiple different answers suggested on here but all does not seem to work with what I am trying to get done. </p>
  
  <p>I am trying to set the option in the select box to selected when picking out the option and submitting it. </p>
  
  <p>I am using switch case because it seems a quicker way to program as oppose to if else statement. </p>
  
  <p>I have iframe on the page. All the targeted links works according to the option but if I try to echo the option that is selected, it will only show the last option selected because it is currently selecting all of my options and that is not what I want. </p>
  
  <p>Here is my code:</p>
  
  <p>PHP:</p>
  
  <pre><code>if (isset($_POST['listings'])){
          $listings = $_POST['listings'];
      } else if (isset($_GET['listings'])) {
          $listings = $_GET['listings'];
      } else {
          $listings = 'chooseListing';
      }
  
      switch ($listings) {
          case 'captivaCondo':
              $iframe = 'http://sancapmls.com/san/idx/index.php?key=09b24ea58e44d14f9f5efed2bfd1edb2';
              $selected = 'selected';
              break;
          case 'captivaResidential':
              $iframe = 'http://sancapmls.com/san/idx/index.php?key=90f72cf9a9a8fe486dff35cede5208b1';
              $selected = 'selected';
              break;
          case 'sanibelCondo':
              $iframe = 'http://sancapmls.com/san/idx/index.php?key=2282d6f0deb849d6a4915685b7677848';
              $selected = 'selected';
              break;
          case 'sanibelResidential':
              $iframe = 'http://sancapmls.com/san/idx/index.php?key=ceb9ec5fc169c6405d234e9b361f8915';
              $selected = 'selected';
              break;
          case 'choose':
              $iframe = 'choose.php';
              $selected = 'selected';
              break;
      }
  </code></pre>
  
  <p>HTML: </p>
  
  <pre><code>    &lt;!-- Search Button --&gt;
      &lt;div class="row"&gt;
          &lt;form role="form"&gt;
          &lt;div class="col-md-8"&gt;
              &lt;select name="listings" class="form-control input-lg"&gt;
                  &lt;option value="choose"&gt;Choose an option&lt;/option&gt;
                  &lt;option value="captivaCondo"&gt;Captiva Condo&lt;/option&gt;
                  &lt;option value="captivaResidential"&gt;Captiva Residential&lt;/option&gt;
                  &lt;option value="sanibelCondo"&gt;Sanibel Condo&lt;/option&gt;
                  &lt;option value="sanibelResidential"&gt;Sanibel Residential&lt;/option&gt;
              &lt;/select&gt;
              &lt;/div&gt;
              &lt;div class="col-md-4"&gt;
              &lt;button type="submit" class="btn btn-primary btn-lg btn-block"&gt;&lt;i class="glyphicon glyphicon-home"&gt;&lt;/i&gt; Search&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;&lt;!-- /.row --&gt;
      &lt;br&gt;
  &lt;!-- iFrame --&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-12"&gt;
              &lt;iframe src="&lt;?php echo $iframe; ?&gt;"&gt;&lt;/iframe&gt;
          &lt;/div&gt;
      &lt;/div&gt; &lt;!-- /.row --&gt;
  </code></pre>
  
  <p>Any help and guide is greatly appreciated!</p>