Re: php and mysql
| From: | David Robley | Date: | Mon, 23 Oct 2000 08:09:41 +0000 |
| Subject: | Re: php and mysql | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21738@lists.php.net to get a copy of this message | ||
On Mon, 23 Oct 2000, Scott Mebberson wrote:
> Hi guys,
>
> I have a small problem and wonder if anyone has had the same problem.
>
> I am using MySQL and PHP for this application. I am retrieving some data
> from the MySQL database. I am using SELECT and then ORDER BY. I am ordering
> it by the content in a feild called elementID which contains numbers (1, 2,
> 3, 4, 5, 6, 7, 8, 9, 10, 11). But when I extract it, MySQL is ordering it
> like Windows Explorer orders files -- 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9 --
> This was cool though, I changed it to be 01, 02 ,03 ,etc and it all work.
> The only thing is though, I was using a php loop to extract the files and
> the loop could only understand the 1, 2, 3, 4 numbering system and not the
> 01, 02, 03
>
> So I am a little screwed. Anybody have a working around for this.
Check the field type - it sounds like it is a string type field (var or
varchar), which would sort in that sequence. You need it to be an numeric
type field for the sort to work correctly.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA