phpBeginner06 Posted January 7, 2007 Share Posted January 7, 2007 How can I sort 3 or more variables in a datatable; that displays in a web page. So far I can only sort two; here is what I have got so far.[code]$result = mysql_query("select * from messeges order by Date, Time desc");[/code]This is what I want to do (but it did not work like this).[quote]$result = mysql_query("select * from messeges order by Date, Time, SpecificTime desc");[/quote]Anyone know how to do this? Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted January 7, 2007 Author Share Posted January 7, 2007 Any one know how to do this? I think you use an array; but I am not sure how to create it and put it in this [code]$result = mysql_query("select * from messeges order by Date, Time desc");"[/code] Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted January 7, 2007 Share Posted January 7, 2007 [code][codeSELECT Company, OrderNumber FROM Orders ORDER BY Company][/code]thats copied from http://www.w3schools.com/sql/sql_orderby.aspyes, your guess was correct. go the website above for more information. hope it helps Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted January 7, 2007 Author Share Posted January 7, 2007 If I do it like this:[code]$result = mysql_query("select * from messeges order by Date, Time desc, SpecificTime desc");[/code]Will the datatable sort in this fashion:[quote]First Sorted By: Date and Then Sorted By: Time, and Finally Sorted By: SpecificTime[/quote]Will it be displayed/sorted like this? Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted January 7, 2007 Share Posted January 7, 2007 well i dont quite understand your last question, but the "desc" at the end of the query means that if you have a table that looks like this:ID User_Name1. User12. User23. User3then you query it by going "SORT BY ID, User_Name desc" ( this meaning sort bi ID first and if record id is == to another record, then sort by User_Name in that record...), youll get these results:ID User_Name3. User32. User21. User1im 99% sure of this, but id like someon to back me upanywayz, try in on your code and see if it works, if not, then let us know, and well come up with another possible solutionGood LuckI hope that helps Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.