In the if condition, you must use a double equal (==) and add an else condition to reset the $select variable to "". Try this:
for ($i=01;$i<=12;$i++) { if($i == date(m)) { $selected = " selected"; }else{ $selected = ""; } print "<option value=\"".date(m,mktime(0,0,0,$i))."\"$selected>".date(F,mktime(0,0,0,$i))." </option>\n"; } Regards Horst > -----Message d'origine----- > De: Dash McElroy [SMTP:[EMAIL PROTECTED]] > Date: mercredi, 1. mai 2002 04:56 > À: Php > Objet: [PHP-WIN] PHP generation of <select> fields > > 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 -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php