you make two mistakes. let's see the correct code:
for ($i=1;$i<=12;$i++)
{
if($i == date(m))
//first here ^^^ (must be == not just one "=")
{
$selected = " selected";
}
//here is the second: if $selected ="selected" for $i=4 (may) $i will be
remain selected for all month > then may
//you need the following line to correct this problem.
else $selected="";
print "<option
value=\"".date(m,mktime(0,0,0,$i))."\"$selected>".date(F,mktime(0,0,0,$i))."
</option>\n";
}
--
Best regards,
George Nicolae
IT Manager
___________________
PaginiWeb.com - Professional Web Design
www.PaginiWeb.com
"Dash McElroy" <[EMAIL PROTECTED]> wrote in message
ABA3F1F1A223D411BE6C006008A6F7E23E6425@MSX1-PTON">news:ABA3F1F1A223D411BE6C006008A6F7E23E6425@MSX1-PTON...
> I am trying to use PHP to generate and automatically select the current
> month in an HTML Form. Here is the code that flails:
>
> for ($i=01;$i<=12;$i++) {
> if($i = date(m)) {
> $selected = " selected";
> }
> print "<option
>
value=\"".date(m,mktime(0,0,0,$i))."\"$selected>".date(F,mktime(0,0,0,$i))."
> </option>\n";
> }
>
> The output is a large amount of April's in the Select dropdown box - my
> machine then goes crazy for a while whilst the hard drive chunks like mad.
>
> Thanks.
>
> -Dash
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php