ORDER BY

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Zeceer
Forum Contributor
Posts: 136
Joined: Fri Aug 02, 2002 5:10 am
Location: Norway

ORDER BY

Post by Zeceer »

I've read the other post here about ORDER BY by it didn't help me much. I've also tried to look for code examples without any luck. Is there something wrong wih the syntax in this code?

Code: Select all

$result = mysql_query( "SELECT * FROM products ORDER BY products DESC" );
Later in the script the $result variable is being used like this:

Code: Select all

while ($row = mysql_fetch_assoc($result))
The script works fine if I remove the ORDER BY products DESC in the $result variable. Like this:

Code: Select all

$result = mysql_query( "SELECT * FROM products" );
User avatar
Zeceer
Forum Contributor
Posts: 136
Joined: Fri Aug 02, 2002 5:10 am
Location: Norway

Post by Zeceer »

I found it out :oops: Problem solved
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Just to make sure, do you have a field in you 'products' table that is named 'products'?

Ie. can you do this:

Code: Select all

$result = mysql_query( "SELECT products FROM products ORDER BY products DESC" );
Post Reply