Re: Incorrect ordering in PHP/MySQL statement
| From: | Joe Stump | Date: | Fri, 22 Dec 2000 19:04:32 +0000 |
| Subject: | Re: Incorrect ordering in PHP/MySQL statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31612@lists.php.net to get a copy of this message | ||
Take the field name of whatever you are sorting (ie productID) and put it in
the sql statement.
ie. SELECT * FROM products WHERE subcat='computers' ORDER BY prodcutID
MySQL defaults to ascending - to make it be descending (ie 10 9 8 7 etc.) put
DESC at the end of your sql statement.
--Joe
On Fri, Dec 22, 2000 at 12:57:18PM -0600, Ben Weinberger wrote:
> Hi~
> I have the following query in a PHP document:
>
> SELECT * FROM products WHERE subcat='test' ORDER BY sort;
>
> This displays all products in the subcategory test and lists them in order
> according to the sort column. However, the order is displayed as follows:
>
> 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, etc.
>
> It should go:
>
> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, etc.
>
> How can I get it to display the products in the correct order?
>
> Thanks,
> -Ben
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
---
Joe Stump
PHP Programmer
www.Care2.com