RE: [PHP] Months of the year

From: Date: Mon, 06 Jan 2003 10:31:54 +0000
Subject: RE: [PHP] Months of the year
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-130378@lists.php.net to get a copy of this message
> How do I create a drop down list that automatically > generates a list of months for the next 12 months upto and including this month This would do it... <select name="st_month" style="width: 80px" class="forms"> <?PHP $curr_month = date("n", mktime()); for ($x = 1; $x <= 12; $x++) { $month_name = date("F", mktime(0, 0, 0, $x, 1, 2002)); if ($x == $curr_month) { echo " <option value=\"$x\" selected>$month_name</option>\n"; } else { echo " <option value=\"$x\">$month_name</option>\n"; } } ?> </select>

« previous php.general (#130378) next »