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
Adding to an Int row in db
Hi, i have a database which houses all of the users of my site. One of the columns is for points whi
Date Question
I'm using the TIMESTAMP() function within mysql to set the date/time for certain events. However, ho
validating url
im trying to validate url's sent to me by a form
the url's im collecting are for placing banners
remove a ; from emails in textarea
Code: <?php
session_start();
$database_host = "localhost&qu
Can I call a class inside a function?
I have a class written in another file that handles my image resizing.
Can I do this (php say
Multi language - seo links
Im trying to figure out the best method to have a multi language website that will function with seo
Buggy registration system
Hey, I just started scripting in PHP, and I ran into a few problems.
Code: <?php
includ
How do I create a 2D game "camera" to follow player?
In J2ME programming I'm targeting MIDP 2.0 devices.
I'm using gamecanvas and I was thinking t
PDO returns erroneous columns from within pdt
Hi All,
This is a truly weird behavior:
When using a simple pdo fetch, erroneous columns a
Need help/w Page: 1,2,3,4 function!
So I have this code im working on where it's ment to display seperate pages having 20 logs each
I