Pull-down select menu works, but won't pre-select
<p>I have a function that take 2 parameters and outputs a select pulldown menu. The first parameter is simply the name, and the second is a parameter ($sel) that holds the selected element (the data is first populated from a db).  This works fine, except the if statement (that determine is used to pre-select an option from the database) doesn't seem to work.  I've verified there should be a match, and that both $sel and date('g:i ', $i) are both strings..so in principle this should work..but it doesn't.</p>

<p>Can you please take a look and see if there is something I'm doing wrong?</p>

<pre><code>function selectTime_Hour($timeName,$sel){
$start = strtotime('1:00am');
$end = strtotime('12:00pm');

$menu = '&lt;select  name="'.$timeName.'"&gt;';
for ($i = $start; $i &lt;= $end; $i += 1800)
{
    if ($sel==date('g:i ', $i)){
      $menu .=  '&lt;option selected="selected"&gt;' . date('g:i ', $i) . '&lt;/option&gt;';
      }
      else {


 $menu .=  '&lt;option value="'.date('g:i',$i).'"&gt;' . date('g:i ', $i) . '&lt;/option&gt;';
}
}
 $menu .= '&lt;/select&gt;';
 return $menu;
</code></pre>

<p>}</p>
