Calculating a rating by adding number of points and dividing by number of items
Posted on
16th Feb 2014 07:03 pm by
admin
I have a site that users can post links to files to download. They can rate these files on a 1-5 scale. I had someone make a Top Rated section for the site, to show the user with the highest rating for their links. However, it just adds a total of points, i.e. if the user has 3 links rated 5/5, their points are 15, if a user has 10 links rated 5/5, their points are 50. It displays the rating based on the number of points, but I would like it to divide the number of points by the number of links. Here is the section of code that deals with the rating calculation, I just don't know enough about syntax to figure out how to divide by the other variable.
Code: (xml) <?xml version="1.0" encoding="utf-8"?>
<sqlmap>
<select id="getTopPoster" resultClass="array">
<![CDATA[
select username, count(linkid) as linkposted from link group by username order by linkposted desc limit 5
]]>
</select>
<select id="getTopRated" resultClass="array">
<![CDATA[
select username, sum(rate) as point from link where rate<>-1 group by username order by point desc limit 5
]]>
</select>
</sqlmap>
I know it is xml code, but I didn't know where else to put it, the rest of the site is built using Prado
No comments posted yet
Your Answer:
Login to answer
319
44
Other forums
close site for maintenance
i get a tutorial, saying the following code can put our site offline, and only the developer can vie
issues verifying if user is logged in
I am having issues when a user logs in via asp Login control, the IsAuthenticated still seems to com
How to assign a textbox value to PHP variable??
Hi ! Can any one help me out as quickly as possible. As I m new to PHP.
Plz tell me how to assign
PHP Multiples of 2, Show posts...not working (wordpress)
I have been using this code to show div.example with 6 li columns inside it, each li is a post with
PHP form help required
Hi all! Apologies in advance for having to message the forum for help. I know you must get a lot of
Upload simple problem
Really confused!! I run once and it worked, but when i tried today...it didn't work
Which par
Anti Spam Code
Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I
Transferring session variables into MySQL
I am trying to transfer $_SESSION variables into MySQL. However there is an error in my MySQL statem
smart reading from a text file
Hello there fellow coders, i was wondering if one of you wouldnt mind helping me with this problem i
How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.
H