Hello again all,
About a month ago, I thought I had fixed all the problems with my rating script on my website. Only now that it's in action, I see another problem.
When I run my script, it is supposed to find the average of the entries in one table of my mySQL database. It is then supposed to decide if that number even exists yet, and if it does, display the average number. If it doesn't exist, it's supposed to say "This attraction has not yet been rated."
Unfortunately, when it displays the rating for attractions that have been rated, it picks the last rating instead of the average. Can anyone tell me why?
Here is my mySQL query:
SELECT AVG(`atrating`) FROM `rating` WHERE `type` = '$type' AND `attractionid` = '$id' GROUP by `atrating`
I've tried getting rid of the "GROUP by" section, but that just eliminates the whole "This attraction has not yet been rated" section.
Please, help me find a way to fix this!
Thanks,
~ Reality15