Jump to content


Easy question - Logic help.

  • Please log in to reply
3 replies to this topic

#1 scottrohe

  • Members
  • PipPip
  • Member
  • 28 posts

Posted 04 September 2006 - 06:19 AM

Hey guys, having some trouble with my logic CAUSE I SUCKKK.

Here's what i'm trying to do. I have a Rating system (0-5 stars). I want to display the 'Top Rated Layouts' when I 'ORDER BY ranking' it works but it displays the first layouts that have been rated with 1 vote / 5 stars.. So, what I need it to do is display the actual TOP rated layouts for example.. If a layout has 3 votes, and its average ranking is still 5 stars, obviously it's better than the layout that has only 1 vote with 5 stars. I have tried 'ORDER BY (ranking*votes)' but that bumps say a layout with a average ranking of 4.80, with 3 votes to the second position above a layout that has like 2 votes with a 5.00 ranking average.

What am I doing wrong in my logic (I suck at math.)? What do I order by? Thanks for your time.

#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 04 September 2006 - 06:28 AM

SELECT ranking, votes FROM mytable ORDER BY ranking DESC, votes DESC
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 scottrohe

  • Members
  • PipPip
  • Member
  • 28 posts

Posted 04 September 2006 - 06:34 AM

Outstanding, it works. Thanks.

#4 corbin

  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 04 September 2006 - 06:35 AM

Oh, wow didnt realize you could double order things like that... Pimp... haha glad i read this post :P
Why doesn't anyone ever say hi, hey, or whad up world?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users