Ordering by numbers???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Ordering by numbers???

Post by Mr. Tech »

I want to record the highest keywords searched. When someone searches it adds the info into the database like this:

id, word, searched

That works fine. When I go to display the results I use this query:

select * from keywords order by search desc

What that does is display the keywords wrong. Instead of going:

1
2
3
4
5
6
7
8
9
10
...
100


It would put:

1
10
100
2
20
3
30
4
40
5
50
6
60
...


How do I get it to show it correctly?

Thanks :)
zenabi
Forum Commoner
Posts: 84
Joined: Mon Sep 08, 2003 5:26 am
Location: UK

Post by zenabi »

Make sure your searched field is of type int and use the following SQL statement:

SELECT * FROM keywords order by searched
Mr. Tech
Forum Contributor
Posts: 205
Joined: Tue Feb 11, 2003 4:18 pm
Location: Australia

Post by Mr. Tech »

Awesome! It worked! Thanks
Post Reply