View Single Post
  #3 (permalink)  
Old 07-23-2008, 05:17 PM
Brett
 
Posts: n/a
Diggs:
Default Re: Please help with tricky array question

Micha,

As always, thanks very much for your help.

I had a little problem with the code as you posted it - I was getting
errors - so after fiddling with it some, I got it to work. I hope I
didn't do something I shouldn't have. The change I made was in the line
with 'selected'. I put a closing double quote just before the colon
and two single quotes after it. It seems to be working just fine. Did
I do something wrong?

> <?php print "<select name='month' id='month'>\n";
> for ($i = 1; $i <= 12; $i++) {
> printf("<option value='%02u'%s>%s</option>\n",
> $i,
> $i == $mysqldate[1] ? " selected='selected' ": '',
> $months[$i-1]
> );
> }
> print "</select>\n"; ?>


Also Micha, I'm not completely clear on how this code works,
particularly <option value='%02u'%s>%s</option>. If it's not too much
trouble would you explain how that works?

Thanks again.

Best,

Brett

Reply With Quote