SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP date problems

    Hi,

    I have been trying to sort this for two days but just can't get my head around it!

    I need two dependant dropdowns. One for months of the year starting with current month and then showing the next 11 months (i've done this,easy enough). The seconf dropdown should show the weeks of the month selected from first dropdown. i.e. First Dropdown=Jul 2009 Second Dropdown would then show weeks like this...

    1. Wednesday 1 July-Sunday 5 July
    2. Monday 6 July - Sunday 12 July
    3. Monday 13 July - Sunday 19 July
    4. Monday 20 July - Sunday 26 July
    5. Monday 27 July - Friday 31 July

    Hope the above makes sense. Been scratching my head on this for two days and any help would be greatly appreciated.

    Cheers,

    Jay

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's another active thread now that I posted some code in which should be useful to you.
    http://www.sitepoint.com/forums/showthread.php?t=627675
    I wrote a function that can produce those weekly date ranges.

    To get your script to respond to the first selection you'll need to either have the user submit as an intermediate step (and then have the script generate the second box in response to the first), or use Javascript and possibly Ajax to load the second box without a page reload.

  3. #3
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats excellent cranial-bore. Thanks very much. It's the exact data that i needed to output.

    Probably a silly question but is there an easy way to get the data out of the produced arrays so that i can echo it out in a loop for producing a dropdown?

    Thanks,

    Jay

  4. #4
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ignore my last post cranial-bore. I've sorted this now. Thanks very much for the excellent code.


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
  •