title: Select box: how to populate days php
body: <p>Recently i ask <a href="https://stackoverflow.com/questions/9370583/select-box-how-to-populate-years-php">how to populate years</a> and i thought that i have all the answer i need. Thing is that i have a new problem with days. The problem seems to be more of mysql than php. In my table users, birthday field, i put "date" as the type which is in this format: 0000-00-00. Now when i use the current select box "day", it inserts 2 instead of 02 and then compromises the whole format when i join $year.$month.$day giving me and output like 1988-11-. How can i solve this? This is the code for days (the year is similar, and it's in the link above). Thanks</p>
  
  <pre><code>&lt;? 
  $bday = $r['birthday'];
  $part = explode("-", $bday);
  $year = $part[0];
  $month = $part[1];
  $day = $part[2]; ?&gt;
  &lt;select name="day"&gt;
      &lt;? for($i = 1; $i &lt;= 31; $i++){?&gt;
      &lt;option value="&lt;? echo $i. '"'; if ($day == $i) {echo 'selected="selected"';}?&gt;"&gt;&lt;?echo $i;?&gt;&lt;/option&gt;  &lt;? }?&gt;
  &lt;/select&gt;
  </code></pre>