Sorting Tables DESC

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
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Sorting Tables DESC

Post by DuFF »

Alright,
I have a mysql table and one of the columns is named rating. Right now I'm trying to sort the contents of my database according to the rating. Here is my query:

Code: Select all

<?php
$query="SELECT * FROM files WHERE category='$category' ORDER BY '$order'";
?>
I have a link that has the following value:

Code: Select all

&lt;a href='$PHP_SELF?category=$category&amp;order=rating'&gt;Rating:&lt;/a&gt;
The link works fine except that it sorts the rating from least to greatest. I tried adding DESC and ASC but nothing worked, the rating is always least to greatest. Does anyone know why?
BTW, the rating type is:
decimal(2,1)
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

sorry did u say you tried this:

Code: Select all

<?php 
$query="SELECT * FROM files WHERE category='$category' ORDER BY '$order' DESC"; 
?>
Post Reply