RE: [PHP] Sort a while loop ?
| From: | Dave Carrera | Date: | Fri, 02 Jan 2004 15:28:54 +0000 |
| Subject: | RE: [PHP] Sort a while loop ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173636@lists.php.net to get a copy of this message | ||
Thanks Tom,
I had a complicated sql line and used my count(var) for the order by
statement and bingo. Just sometimes you forget the obvious an need a kick up
the **** :-)
Dave C
-----Original Message-----
From: Tom Rogers [mailto:trogers@kwikin.com]
Sent: 02 January 2004 15:22
To: Dave Carrera
Cc: php-general@lists.php.net
Subject: Re: [PHP] Sort a while loop ?
Hi,
Saturday, January 3, 2004, 1:12:49 AM, you wrote:
DC> Hi List,
DC> How can I sort a while loop or do something before it to achieve the
DC> following?
DC> I have a MySql result fetching something like this:
DC> Id Name Number
DC> 1 Bob 34567
DC> 2 Ben 234
DC> 3 Jeff 4567
DC> 4 Dave 2345
DC> But I want to sort the while loop by Number Highest first so the
DC> result looks like this:
DC> Id Name Number
DC> 1 Bob 34567
DC> 2 Jeff 4567
DC> 3 Dave 2345
DC> 4 Ben 234
DC> I have looked at sort() asort() and others in the manual and either
DC> I am doing something wrong (which is more than likely) or a while
DC> loop is not what I need to use to achieve this.
DC> Thank you in advance for any help
DC> Dave C
DC> P.S: Happy New Year to you all.
DC> ---
DC> Outgoing mail is certified Virus Free.
DC> Checked by AVG anti-virus system (http://www.grisoft.com).
DC> Version: 6.0.556 / Virus Database: 348 - Release Date: 26/12/2003
add
ORDER BY number DESC
to your mysql query
--
regards,
Tom
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 26/12/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.556 / Virus Database: 348 - Release Date: 26/12/2003