Gavin Newsom - Electronics - PS2 Xbox Nintendo Dreamcast Games - Free Articles Directory About Cancer - Deaf Topics

PDA

View Full Version : Numerical sequesnce problem


jc@ukzone.com
Mar 11th 2008, 4:46 am
I have a message board that runs in php/mysql. It lists the messages in numerical sequence in decending order:
$qry .= " ORDER BY reference DESC" ;

This has worked fine until now.
The numbers got up to 9999 and then the next number is 10000 was displayed at the bottom or the list.
Numbers are generated from a text file, which increments OK (it is now on 10013).

Does anybody know why this has happened and is there a cure for it.

Thanks

John C

CreativeClans
Mar 11th 2008, 9:10 am
Is reference defined as numeric or as text?
It should be numeric, otherwise ordering won't give you the desired result. Unless you change all numbers smaller than '10000' in '09999', '09998', etc (notice the leading zero).

By the way, if you're using an incrementing order number, why don't you use the MYSQL AUTOINCREMENT feature?

jc@ukzone.com
Mar 11th 2008, 9:21 am
Hi CreativeClans (Grunt)

Thanks for your response.
I didn't think about the type. I had it set to VARCHAR and changed it to INT and it now works fine.

The idea of using the auto increment function appeals to me.
I used a text file when the board was run in perl so I just continued with it.

If I use the auto increment, how would I start it to continue from where it is now? Do I just change the field to auto_increment and set the default to the present number?

You help is very much appreciated.

John C

CreativeClans
Mar 11th 2008, 9:54 am
Hmm, don't know about that. Sorry. Maybe someone else?