Re: Sort a while loop ?
| From: | Martin Helie | Date: | Fri, 02 Jan 2004 15:28:32 +0000 |
| Subject: | Re: Sort a while loop ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173637@lists.php.net to get a copy of this message | ||
Since you mention mysql, why not just add
"ORDER BY number DESC" to your query? The database will do the work for you.
"Dave Carrera" <dave@ephgroup.com> wrote in message
news:001501c3d142$e2bb7a90$0301a8c0@daveslaptop...
> Hi List,
>
> How can I sort a while loop or do something before it to achieve the
> following?
>
> I have a MySql result fetching something like this:
>
> Id Name Number
> 1 Bob 34567
> 2 Ben 234
> 3 Jeff 4567
> 4 Dave 2345
>
> But I want to sort the while loop by Number Highest first so the result
> looks like this:
>
> Id Name Number
> 1 Bob 34567
> 2 Jeff 4567
> 3 Dave 2345
> 4 Ben 234
>
> I have looked at sort() asort() and others in the manual and either I am
> doing something wrong (which is more than likely) or a while loop is not
> what I need to use to achieve this.
>
> Thank you in advance for any help
>
> Dave C
>
> P.S: Happy New Year to you all.
>
> ---
> 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
>