Another solution: $month_now = date("n"); echo "<select name=\"month\">\n"; for($i=$month_now, $j=0; $i<=($month_now+12); $i++,$j++) { echo "<option value=\"$i\""; if($i == $month_now) { echo " selected"; } echo ">" . date("F Y", mktime(0, 0, 0, $month_now+$j, 1, date("Y"))) . "</option>\n"; } echo "</select>\n";
This will start the month's dropdown on the month of the year through to the month of the following year, e.g. January 2003 to January 2004, February 2003 to February 2004, etc. James "David Freeman" <[EMAIL PROTECTED]> wrote in message 006e01c2b56e$d559fe30$0b0a0a0a@skink">news:006e01c2b56e$d559fe30$0b0a0a0a@skink... > > > 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> > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php