Re: Month

From: Date: Mon, 19 Feb 2007 18:36:49 +0000
Subject: Re: Month
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-249034@lists.php.net to get a copy of this message
If I change my date value to m instead of M, that would only affect the visual month representation that they see, and not the "selected" value that I want to input into my database though....right? On 2/19/07, Jay Blanchard <jblanchard@pocket.com> wrote:
[snip] I have the following code which populates a dropdown box so a user can select a month. They see the month name and the SELECTED value is the corresponding numeric value 1-12 for the month. However, the selected value for January would be 1. I need the selected value fro January to be 01. How would I accomplish this? <select name="month"> <?PHP
    for ($m=1;$m<=12;$m++)
    {
     $months=date('M', mktime(0, 0, 0, $m, 1));
     if ($m == $_POST['month'])
      echo "<option value=\"{$m}\" SELECTED>{$months}</option>";
     else
      echo "<option value=\"$m\">$months</option>";
    }
?> </select> [/snip] http://www.php.net/date


« previous php.general (#249034) next »