Query Problem!

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
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Query Problem!

Post by Joe »

I am currently developing my very own who's online script for my site and I came across a small problem. Everything so far works just perfect apart from the fact that my query information isn't going my way. I am trying to create it so names are ordered by name and level. For example level 1 is administrator and level 0 is normal user. I wish for it to show admins first aswell order by the name. It is very complicated to explain this but is there any way of ordering in a query twice like:

$sql = "SELECT * FROM online WHERE time <> '0' ORDER BY name AND ORDER BY level";

Please help? Thanks!
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

not sure tbh

try

Code: Select all

ORDER BY name AND GROUP BY level
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Hmm all I got was a query error. I will try to work this out :) Thanks bud!
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Your SQL query is incorrect, it should be written as:

$sql = "SELECT * FROM online WHERE time <> '0' ORDER BY name, level";
Post Reply