PHP - How do i rank my search result - Asked By Olusegun A. on 18-Jul-10 11:18 AM

Hello Friends,

I am building a website where the membership will be in 3 categories; class1, class2 & class3. each member in these 3 categories can add their products to my database to appear on my home page. I know how to display these added products on my home page but what i want to do is that i want the products being added by the class3 members to appear on top then follow by the products of class2 members and then products of class1 to come last. pls how do i do this.

regards,
adsegzy
Sasha Kotlo replied to Olusegun A. on 18-Jul-10 03:03 PM
Well you can do that using SQL query itself. Now let's say your default sorting format is by Price and let's say your product entry has a memberClassID. You would do the following:

"SELECT * FROM Products ORDER BY memberClassID DESC, Price"

What desc here does is order the results first and foremost by memberClassID (from highest to lowest and therefore class3 would be first) and then by Price in ASCENDING order.

Best regards.