title: Retrive a date from a database in three dropdown list
body: <p>I need to retrive a date from database in three dropdown lists.
  Mysql &amp; PHP code:</p>
  
  <pre><code>if (mysqli_connect_errno()) {
     echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  else {
    $sql = "SELECT ui.`sex` AS ui_sex , 
    ui.`last_name` AS ui_lname, 
    ui.`first_name` AS ui_fname, 
    ui.`nickname` AS ui_nickname, 
    ui.`nin` AS ui_nin, 
    ui.`birth_date` AS ui_birth,             
    WHERE ui.`userid` = 1";
  $result = mysqli_query($con, $sql);
  $count = mysqli_num_rows($result);
  if ($count == 0) {
    echo '&lt;h4&gt;No data submited yet.&lt;/h4&gt;';
  }
  else{
     while ($row = mysqli_fetch_array($result)) {
        $ui_sex = $row['ui_sex'];
        $ui_nume = $row['ui_lname'];
        $ui_prenume = $row['ui_fname'];
        $ui_nickname = $row['ui_nickname'];
        $ui_nin = $row['ui_nin'];
        $ui_birth = $row['ui_birth'];
     }
  }
  </code></pre>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;form action="submit_values.php" method="POST"&gt;
  &lt;!-- Code for previous fields --&gt;
  &lt;label class='small-3 columns label_inf_clients'&gt;Day of birth*:&lt;/label&gt;
          &lt;div class="small-6 columns select_tag_bottom_margin"&gt; 
              &lt;select id="select_day" name="day" &gt;
      &lt;?php
          //the next option should store the day from $birth_date
           echo'&lt;option class="option_an" value='.$day.'&gt;'.$day.'&lt;/option&gt;';
  
      ?&gt;
      &lt;?php
      for ($i = 1; $i &lt;= 31; $i++) {
          echo'&lt;option  class="option_an" value=' . $i . "&gt;" . $i . '&lt;option&gt;';
      }
      ?&gt;
              &lt;/select&gt;
  
         &lt;select class="select_month" name="month"&gt;
              &lt;?php
                 //the next option should store the month from $birth_date
                echo'&lt;option class="option_an" value='.$month.'&gt;'.$month.'&lt;/option&gt;';
              ?&gt;
              &lt;option value="01"&gt;Jan&lt;/option&gt;
               .............................
              &lt;option value="11"&gt;Nov&lt;/option&gt;
              &lt;option value="12"&gt;Dec&lt;/option&gt;
          &lt;/select&gt;
          &lt;select class="select_year" name="an"&gt;
      &lt;?php
          //the next option should store the year from $birth_date
                echo'&lt;option class="option_an" value='.$year.'&gt;'.$year.'&lt;/option&gt;';
      for ($i = 2013; $i &gt;= 1940; $i--) {
          echo'&lt;option  class="option_an" value=' . $i . "&gt;" . $i . '&lt;option&gt;';
      }
      ?&gt;
      &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So let's recap: from database I select the birth date, which is stored in $ui_birth, I want so split  this date in 3 dropdown lists, like in next picture: <a href="https://docs.google.com/file/d/0B44T4qmqQGHAY3JkdFZNOGdLTW8/edit?usp=sharing" rel="nofollow">https://docs.google.com/file/d/0B44T4qmqQGHAY3JkdFZNOGdLTW8/edit?usp=sharing</a></p>