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

Including calander to page - will not show other months than current??
im trying to add an existaing calander onto a profile page by using Code: <?php include "

Using system() and bringing back the results
I am aware that you can use system() within PHP to execute system commands, but I was wondering if t

I got my hosting suspended XD
So I saw this challenge a day or so ago

http://www.programming-challenges.com/pg.php?page=dow

Email Form Syntax Issue
I need the TO: in email to display To: CEO instead of To: abc@mail.com

How to alter the scri

Replacing a string on click of a button
Hi! Is there a way to replace a string on a click of a text link?

This is what I've come up w

value not going in data base
hello friends....
i am having a working javascript....when i am selecting any

Can we convert non uni code system into unicode
Hi All,

Presently i am using non-unicode system and the sap version is 4.7.
Can i c

Agency Business Process
Hi,

I don’t understand the process of the agency business in SAP.

In my

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

adding up might be solved tell us cheers.
i think i finally solved this anybody.

last time i was getting the wrong results.

Code

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