Results 1 to 4 of 4

Thread: [php] Month/Year Select Box

  1. #1
    Roll Tide! mobilebadboy's Avatar
    Join Date
    Apr 2004
    Location
    Mobile, AL
    Posts
    428

    [php] Month/Year Select Box

    I've been trying to wrap my head around this for a long time now. In my head I know the theory of what needs to be done but every time I sit and try to type out the code, my mind goes blank.

    I have a form with a Month/Year format (combined) and the first date is always the current month/year followed by 17 future months + incremented year when needed, ie:

    Code:
    <option value="9/1/2009">September 2009</option>
    <option value="10/1/2009">October 2009</option>
    <option value="11/1/2009">November 2009</option>
      ..... .....
    <option value="12/1/2010">December 2010</option>
    <option value="1/1/2011">January 2011</option>
    <option value="2/1/2011">February 2011</option>
    Currently this is updated manually and I often forget to do it, which is why I'd like to finally get this straight and forget it. The year rollover part, 09 > 10 > 11, etc, is one of my major hangups (another thing I can imagine in my head, but not get in to code).

    I've searched and searched, everything that I have found is separated in to multiple select menus.
    Shawn Kerr .com

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    MAybe use a multidimensional array populated automatically then read from?
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    ... or easier... use php to get the number of the current month, and current year.

    PHP Code:
    for($i=0;$i<18;$i++){

    echo 
    $month."/1/".$year;

    if((
    $month 12) == 0){
    $year++;
    $month=0;
    }

    $month++;


    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  4. #4
    Roll Tide! mobilebadboy's Avatar
    Join Date
    Apr 2004
    Location
    Mobile, AL
    Posts
    428
    Awesome, thanks Chris. I was in that area, but still way off, especially on that if operator.
    Shawn Kerr .com

Similar Threads

  1. Trying to SELECT *, MATCH() with two columns
    By NevadaSam in forum Website Programming & Databases
    Replies: 5
    Last Post: 05-24-2007, 04:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •