Jump to content

[SOLVED] How would I arrange these by average rating?


netstormx

Recommended Posts

I made a function out of this, and I'm trying to arrange the output by the average ratings out of 5 stars, higher showing up higher obviously. Right now it's not working right. This is currently showing based on number of total ratings towards the top. Anything I missed? Thanks.

 

$sql = "SELECT COUNT(ratings.id) as rates,ratings.rating_id,".$table.".".$idfield." as gameid,".$namefield." as thenamefield,".$img." as gameimage,".$type." as gameurl,ROUND(AVG(ratings.rating_num),2) as rating

 

FROM ratings,".$table." WHERE ".$table.".".$idfield." = ratings.rating_id GROUP BY rating_id

 

ORDER BY rates DESC,rating DESC LIMIT ".$limit."";

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.