Generating a selection box for the day of the month
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.