title: option selected value and optgroup PHP
body: <p>i have a similar code as this which is pretty works fine but i am looking a way to make the codes shorter, but i don't have any idea how to do this because it checks the selected value from the DB then have the option selected + the option has its own optgroup</p>
  
  <pre><code>&lt;select name="server"&gt;
    &lt;?php if ($server == 'A') { ?&gt;
    &lt;optgroup label="Label 1"&gt;
      &lt;option value="A" selected="selected"&gt;A&lt;/option&gt;
      &lt;option value="B"&gt;B&lt;/option&gt;
    &lt;/optgroup&gt;
    &lt;optgroup label="Label 2"&gt;
      &lt;option value="C"&gt;C&lt;/option&gt;
      &lt;option value="D"&gt;D&lt;/option&gt;
    &lt;/optgroup&gt;
    &lt;?php } else if ($server == 'B') { ?&gt;
    &lt;optgroup label="Label 1"&gt;
      &lt;option value="A"&gt;A&lt;/option&gt;
      &lt;option value="B" selected="selected"&gt;B&lt;/option&gt;
    &lt;/optgroup&gt;
    &lt;optgroup label="Label 2"&gt;
      &lt;option value="C"&gt;C&lt;/option&gt;
  
  and so on...
  </code></pre>
  
  <p>did you guys have any idea how to do this in php?
  any help is appreciated, thank you </p>