Re: Incorrect ordering in PHP/MySQL statement

From: Date: Fri, 22 Dec 2000 19:03:53 +0000
Subject: Re: Incorrect ordering in PHP/MySQL statement
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-31611@lists.php.net to get a copy of this message
On Fri, 22 Dec 2000, 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 > Store sort as a numeric (INT etc.) type, not as a string type (CHAR etc.). -- Ignacio Vazquez-Abrams <ignacio@openservices.net>

« previous php.general (#31611) next »