RE: [PHP-WIN] PHP generation of <select> fields

From: Date: Wed, 01 May 2002 08:18:30 +0000
Subject: RE: [PHP-WIN] PHP generation of <select> fields
Groups: php.windows 
Request: Send a blank email to php-windows+get-13449@lists.php.net to get a copy of this message
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:Dash@westonefcu.org] > 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

« previous php.windows (#13449) next »