Page 1 of 1

Mysql and Numbers

Posted: Wed Sep 07, 2005 1:18 am
by Mr Tech
I have this query:

Code: Select all

$query = mysql_query("select * from {$tbl_name}products_items where cat='$cat' order by priority asc");
priority is a number. It can be any number (1, 1.1, 100, 2000.50 etc etc) and it needs to allow me to add dots in the numbers.

When I have priority set to something like INT(10) in phpMyAdmin, it doesn't allow dots. I then changed it to VARCHAR to see if it would allow dots and it did.

However, it did not order the numbers correctly. Instead of ordering it the correct way which is:

1, 50, 100, 200

It ordered incorrectly:

1, 100, 200, 50

How can I make it allow dots but also order correctly?

Posted: Wed Sep 07, 2005 1:23 am
by feyd
use a precision type, like FLOAT or DOUBLE


fyi: when strings/characters (like VARCHAR is), the second result is correct.

Posted: Wed Sep 07, 2005 4:34 am
by Mr Tech
Thanks feyd :wink: