netstormx Posted July 26, 2009 Share Posted July 26, 2009 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.""; Link to comment https://forums.phpfreaks.com/topic/167535-solved-how-would-i-arrange-these-by-average-rating/ Share on other sites More sharing options...
Daniel0 Posted July 26, 2009 Share Posted July 26, 2009 Well, of course it does Check out this part: ORDER BY rates DESC,rating DESC Just remove the first one. Link to comment https://forums.phpfreaks.com/topic/167535-solved-how-would-i-arrange-these-by-average-rating/#findComment-883446 Share on other sites More sharing options...
netstormx Posted July 26, 2009 Author Share Posted July 26, 2009 Thanks Daniel, I must have added that in there on accident. That solved the issue, thanks. Link to comment https://forums.phpfreaks.com/topic/167535-solved-how-would-i-arrange-these-by-average-rating/#findComment-883472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.