title: How to generate dynamic selectbox with optgroup
body: <p>Hi I am having this mysql table.</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `selling_counties` (
    `county_id` int(11) NOT NULL auto_increment,
    `country` varchar(20) collate utf8_unicode_ci NOT NULL,
    `county_name` varchar(25) collate utf8_unicode_ci NOT NULL,
    `datecreated` datetime NOT NULL,
    `datemodified` datetime NOT NULL,
    PRIMARY KEY  (`county_id`)
  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=97 ;
  </code></pre>
  
  <p>and I need have a selectbox with optgroup where country will be  and county_name will the s
  such as</p>
  
  <pre><code>&lt;select name ="county"&gt;
      &lt;optgroup label="England"&gt;
          &lt;option&gt;South Yorkshire&lt;/option&gt;
          &lt;option&gt;Staffordshire&lt;/option&gt;
          &lt;option&gt;Suffolk&lt;/option&gt;
          &lt;option&gt;Surrey&lt;/option&gt;
          &lt;option&gt;Tyne and Wear&lt;/option&gt;
          &lt;option&gt;Warwickshire&lt;/option&gt;
          &lt;option&gt;West Midlands&lt;/option&gt;
          &lt;option&gt;West Sussex&lt;/option&gt;
          &lt;option&gt;West Yorkshire&lt;/option&gt;
          &lt;option&gt;Wiltshire&lt;/option&gt;
          &lt;option&gt;Worcestershire&lt;/option&gt;
      &lt;/optgroup&gt;
      &lt;optgroup label="Wales"&gt;
          &lt;option&gt;Clwyd&lt;/option&gt;
          &lt;option&gt;Dyfed&lt;/option&gt;
          &lt;option&gt;Gwent&lt;/option&gt;
          &lt;option&gt;Gwynedd&lt;/option&gt;
          &lt;option&gt;Mid Glamorgan&lt;/option&gt;
          &lt;option&gt;Powys&lt;/option&gt;
          &lt;option&gt;South Glamorgan&lt;/option&gt;
          &lt;option&gt;West Glamorgan&lt;/option&gt;
      &lt;/optgroup&gt;
      &lt;optgroup label="Scotland"&gt;
          &lt;option&gt;Aberdeenshire&lt;/option&gt;
          &lt;option&gt;Angus&lt;/option&gt;
          &lt;option&gt;Argyll&lt;/option&gt;
          &lt;option&gt;Selkirkshire&lt;/option&gt;
          &lt;option&gt;Shetland&lt;/option&gt;
          &lt;option&gt;Stirlingshire&lt;/option&gt;
          &lt;option&gt;Sutherland&lt;/option&gt;
          &lt;option&gt;West Lothian&lt;/option&gt;
          &lt;option&gt;Wigtownshire&lt;/option&gt;
      &lt;/optgroup&gt;
      &lt;optgroup label="Northern Ireland"&gt;
          &lt;option&gt;Antrim&lt;/option&gt;
          &lt;option&gt;Armagh&lt;/option&gt;
          &lt;option&gt;Down&lt;/option&gt;
          &lt;option&gt;Fermanagh&lt;/option&gt;
          &lt;option&gt;Londonderry&lt;/option&gt;
          &lt;option&gt;Tyrone&lt;/option&gt;
      &lt;/optgroup&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I have already tried this <a href="https://stackoverflow.com/questions/5132166/php-dynamic-drop-down-with-optgroup">PHP: Dynamic Drop down with optgroup</a>
  but it is bit complex for me as I am newbie with php, moreover it is coming from 2 seperate tables and mine is coming from same table.</p>
  
  <p>Any help will be highly appreciable.</p>