I'm writing a script that will show the most visited profiles on my site, the top 10 to be exact. Now I understand how to select from the table by the number of visits and use DESC to start with the highest and work down, but when i do this the following is what comes out:
User 1|43
User 2|345
User 3|21
User 4|2001
So it only orders them by the first digit. How do I get it to look at the number as a whole (preferably without adding leading zeros..)SELECT usernumber, visits FROM database, ORDER BY visits
^^^^^^That wasnt my question. I said I know how to do that. Read my post again..ah yes I see now. I think what is happening is that the visits field is a string, not an integer. Get into PHPMyAdmin and change the field type to INT
or use the query
ALTER TABLE `database`.`yourtable` CHANGE `visits` `visits` INT
but I suggest your use PHPAdmin
User 1|43
User 2|345
User 3|21
User 4|2001
So it only orders them by the first digit. How do I get it to look at the number as a whole (preferably without adding leading zeros..)SELECT usernumber, visits FROM database, ORDER BY visits
^^^^^^That wasnt my question. I said I know how to do that. Read my post again..ah yes I see now. I think what is happening is that the visits field is a string, not an integer. Get into PHPMyAdmin and change the field type to INT
or use the query
ALTER TABLE `database`.`yourtable` CHANGE `visits` `visits` INT
but I suggest your use PHPAdmin