Re: Date Sorting
| From: | Ray Hunter | Date: | Wed, 01 Oct 2003 14:09:39 +0000 |
| Subject: | Re: Date Sorting | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164547@lists.php.net to get a copy of this message | ||
Try using any of the sort functions:
sort
asort
arsort
ksort
krsort
...
That should get you started.
--
Ray
On Wed, 2003-10-01 at 07:18, Greg Wiley wrote:
> Apologies if this has been asked before but I couldn't find
> anything on google or any of the PHP code sites that quite fits my
> requirements. Here's the problem:
>
> I have a form which presents the user with a table of dates with
> checkboxes for a three month period, e.g.
>
> Dec 7th 14th 21st 28th
> am [ ] [ ] [ ] [ ]
> pm [ ] [ ] [ ] [ ]
>
> Jan 4th 11th 18th 25th
> am [ ] [ ] [ ] [ ]
> pm [ ] [ ] [ ] [ ]
>
> Feb 1st 8th 15th 22nd 29th
> am [ ] [ ] [ ] [ ] [ ]
> pm [ ] [ ] [ ] [ ] [ ]
>
> When the user submits the form with any of the boxes checked I
> want to have these sorted into date order.
>
> If I check Dec 28th am and pm, Jan 4th am and pm, Jan 18th am and
> pm and Feb 15th am and pm then the order returned in the _POST is:
>
> Dec 28 am, Dec 28 pm, Jan 4 am, Jan 18 am, Jan 4 pm, Jan 18 pm,
> Feb 15 am, Feb 15 pm
>
> This is, I believe, due to the order of the elements in the form.
> I tried using tabindex to influence the order returned but to no
> avail. So I'm now trying to do this in the php code that processes
> the submission. There is no year info such that I could turn the
> dates into timestamp and sort that way. Has anyone got any code
> that can sort this correctly?
>
> Cheers, Greg.
> --
> Greg Wiley
> http://wileysworld.org/