title: Populating user birthday in dropdowns from database with php
body: <p>I have user system on the site. When user is registering he select his date of birth also. I'm storing this date in table in this format <code>1900-01-01</code>.</p>
  
  <p>Now I want to make page from where users can edit their account and also to change date of birth..</p>
  
  <p>Problem: How to populate 3 dropdowns Year, Month, Day when in database table is stored as one? </p>
  
  <p>So this is the query when user open edit page:</p>
  
  <pre><code>SELECT * FROM users WHERE id = ? LIMIT 1
  </code></pre>
  
  <p>and the dropdowns..</p>
  
  <pre><code>&lt;select name="year" id="year" class="form-control"&gt;
      &lt;option value="--"&gt;Year&lt;/option&gt;
          &lt;?php for($i=date('Y'); $i&gt;1899; $i--) {
              $birthdayYear = '';
              $selected = '';
              if ($birthdayYear == $i) $selected = ' selected="selected"';
              print('&lt;option value="'.$i.'"'.$selected.'&gt;'.$i.'&lt;/option&gt;'."\n");
          } ?&gt;
  &lt;/select&gt;
  &lt;select name="month" id="month" onchange="" class="form-control" size="1"&gt;
      &lt;option value="--"&gt;Month&lt;/option&gt;
      &lt;option value="01"&gt;January&lt;/option&gt;
      &lt;option value="12"&gt;...&lt;/option&gt;                     
      &lt;option value="12"&gt;December&lt;/option&gt;
  &lt;/select&gt;   
  &lt;select name="day" id="day" onchange="" class="form-control" size="1"&gt;
      &lt;option value="--"&gt;Day&lt;/option&gt;
      &lt;option value="01"&gt;01&lt;/option&gt;
      &lt;option value="..."&gt;...&lt;/option&gt;
      &lt;option value="31"&gt;31&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Is it possible this or I must store each value in different column in database?</p>
  
  <p>Update:</p>
  
  <pre><code>result = $pdo-&gt;prepare("SELECT * FROM users WHERE id = ? LIMIT 1");
  $result -&gt; bindParam(1, $id, PDO::PARAM_INT);
  $result -&gt; execute();
  foreach ( $result as $row )             
  {
        $birthDay = $row['user_birthday'];                 
        $explodeBirthDay = explode('-',$birthDay);
        $birthdayYear = $explodeBirthDay['0'];
        $birthdayMonth = $explodeBirthDay['1'];
        $birthdayDay = $explodeBirthDay['2'];             
        echo '    
            &lt;div class="form-group"&gt;                     
               &lt;label class="col-md-4 control-label" for="birthday"&gt;&lt;/label&gt;
                  &lt;div class="col-md-2"&gt;
                    &lt;div class="form-group"&gt;
                      &lt;select name="year" id="year" class="form-control"&gt;
                          &lt;option value="--"&gt;Year&lt;/option&gt;';                                                      
                          for($i=date('Y'); $i&gt;1899; $i--) {
                              $selected = '';
                              if ($birthdayYear == $i) $selected = ' selected="selected"';
                              print('&lt;option value="'.$i.'"'.$selected.'&gt;'.$i.'&lt;/option&gt;'."\n");
                          }                           
                      echo'   
                          &lt;/select&gt;       
                      &lt;/div&gt;
                   &lt;/div&gt;     
                   &lt;div class="col-md-2"&gt;
                     &lt;div class="form-group"&gt;
                       &lt;select name="month" id="month" onchange="" class="form-control" size="1"&gt;
                         &lt;option value="--"&gt;Month&lt;/option&gt;
      &lt;option  if($birthdayMonth == "01") { ?&gt; selected="selected" &lt;?php } ?&gt; value="01"&gt;January&lt;/option&gt;
  
      &lt;option  if($birthdayMonth == "12") { ?&gt; selected="selected" &lt;?php } ?&gt;value="12"&gt;December&lt;/option&gt;
                           &lt;/select&gt;            
                          &lt;/div&gt;     
                        &lt;/div&gt;
                   &lt;div class="col-md-2"&gt;         
                      &lt;div class="form-group"&gt;
                          &lt;select name="day" id="day" onchange="" class="form-control" size="1"&gt;
                          &lt;option value="--"&gt;Day&lt;/option&gt;
      &lt;option &lt;?php if($birthdayDay == "01") { ?&gt; selected="selected" &lt;?php } ?&gt; value="01"&gt;01&lt;/option&gt;
      &lt;!-- remaining days --&gt;
        &lt;option &lt;?php if($birthdayDay == "31") { ?&gt;selected="selected" &lt;?php } ?&gt; value="31"&gt;31&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/div&gt;                      
                  &lt;/div&gt;                      
          &lt;/div&gt;                                      
  </code></pre>