Generating a selection box for the day of the month &lt;select name="checkInDay" tabindex="3" onchange="calcDay();" class="ffe selectform" id="checkInDate"&gt;
    &lt;?php for($i=1;$i&lt;=31;$i++) {
        $value = $i &lt; 10 ? "0".$i : $i;
     ?&gt; 
     &lt;option value="&lt;?= $value ?&gt;" &lt;?php if($i == 12) {?&gt; selected="selected" &lt;?php } ?&gt; &gt; &lt;?= $i ?&gt; &lt;/option&gt;
     &lt;?php } ?&gt;

  &lt;/select&gt;
I suggest to build a function which can be reused for the options:

function select_options($options, $selected = null) {
  $_options = '';
  foreach ($options as $value =&gt; $content) {
    $_options .= sprintf("&lt;option value=\"%s\"%s&gt;%s&lt;/option&gt;\n", $value, $value == $selected ? ' selected="selected"' : '', $content);
  }

  return $_options;
}


And some PHP "magic" for the values generation but it is not really needed:

&lt;?php $values = array_map(create_function('&amp;$v', 'return sprintf("%02d", $v);'), range(1, 31)) ?&gt;
&lt;select name="checkInDay" tabindex="3" onchange="calcDay();" class="ffe selectform" id="checkInDate"&gt;
  &lt;?php echo select_options(array_combine($values, range (1, 31)), 12) ?&gt;
&lt;/select&gt;


But more important than all: in a HTML template, use the PHP alternative notation.