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 Like 44 Dislike
Previous forums Next forums
Other forums

Displaying a clickable playername
I am going wrong somewhere with the mysql_query, can someone please put me straight?

$playern

please help me in this update statment
hi every one

if I have table and this data in it

id name
10

php multiple action on submit
I have a form which says:

<form enctype='multipart/form-data' method='post' action='pr

Passing variables with pagination - iterating through unique id per link
Hi everyone,
I have seen a few topics like this one. Still cant find the specific thing, so I am

PHP & Images [Resize, Crop, Save]
Hey! Well I have a little dilema, hoping I could find some guidance.

I have a CMS and on the

Dynamically allocating the number of rows in a table based on a variable value
Hi,
I have situation here which i cannot resolve, I have a variable temp which stores the num

Ball movement
I want to move a ball from one point to another and it should hit a group of balls at the other end

Struct/union and scope problem!
HI all , I have
Code: in header.h typedef struct Node Link; /* ---------

how to validate date using javascript
I need to validate date in textbox using javascript..
The date is must be not greater than TODAY

search function
HI guys,

if anyone could point us in the right direction of how to do this, or provide some t

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash