Jump to content

How To Sort Data Table By 3 or More Variable?


phpBeginner06

Recommended Posts

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?
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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_Name
1.      User1
2.      User2
3.      User3

then 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_Name
3.      User3
2.      User2
1.      User1


im 99% sure of this, but id like someon to back me up

anywayz, try in on your code and see if it works, if not, then let us know, and well come up with another possible solution

Good Luck

I hope that helps
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.