Re: [PHP] Date Sorting

2003-10-01 Thread Ray Hunter
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 14th21st28th
   am  [ ] [ ] [ ] [ ]
   pm  [ ] [ ] [ ] [ ]
 
 Jan   4th 11th18th25th
   am  [ ] [ ] [ ] [ ]
   pm  [ ] [ ] [ ] [ ]
 
 Feb   1st 8th 15th22nd29th
   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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Date Sorting

2003-10-01 Thread Jason Wong
On Wednesday 01 October 2003 21: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 14th21st28th
   am  [ ] [ ] [ ] [ ]
   pm  [ ] [ ] [ ] [ ]

 Jan   4th 11th18th25th
   am  [ ] [ ] [ ] [ ]
   pm  [ ] [ ] [ ] [ ]

 Feb   1st 8th 15th22nd29th
   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?

Incorporate whatever sorting info you need into the value of the checkbox.

  input type=checkbox 
 name=Dec 28 am 
 value=insert timestamp for Dec 28 or whatever

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
leverage, n.:
Even if someone doesn't care what the world thinks
about them, they always hope their mother doesn't find out.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Date Sorting

2003-10-01 Thread Greg Wiley
 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED] 
[problem snipped]
 
 Incorporate whatever sorting info you need into the value of 
 the checkbox.
 
   input type=checkbox 
  name=Dec 28 am 
  value=insert timestamp for Dec 28 or whatever
 

Thanks, someone else suggested this and I think this is the method
I shall use.

Cheers, Greg.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Date Sorting

2003-10-01 Thread Greg Wiley
 -Original Message-
 From: Greg Wiley [mailto:[EMAIL PROTECTED] 
 
  -Original Message-
  From: Jason Wong [mailto:[EMAIL PROTECTED]
 [problem snipped]
  
  Incorporate whatever sorting info you need into the value of
the 
  checkbox.
  
input type=checkbox 
   name=Dec 28 am 
   value=insert timestamp for Dec 28 or whatever
  
 
 Thanks, someone else suggested this and I think this is the 
 method I shall use.
 
And this was the method that worked! Thanks for all those who took
the trouble to respond you've helped fixed a problem that's been
bugging me for a couple of days.

Cheers, Greg.
-- 
Greg Wiley
http://wileysworld.org/ 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php