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
Searching keywords from array
Hello everyone, Im just wondering if someone could help me with another issue im having. Im still le
SAP Business Suite
Hi all:
Within the SAP Business Suite solution I would like to ask you the main differenc
error help - Dynamic Image
I've been working on making my site less cluttered in the directories and more secure lately. In an
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
session checking in page load
hai all
I have a web site is www.Mryas.com in this my login page is Page1.aspx its co
Echo-ing MySQL content and Keep Formatting?
I have data in my MySQL such as:
QuoteBlah blah
Blah blah
etc
but when i ech
date("now") prints out wrong date ?
Hi Guys
Anyone know why and how I can fix it ?
mysqli_fetch_assoc returns multiple arrays, how to return a single array
Hello, I am using mysqli_fetch_assoc which is returning multiple rows, so it looks like:
Code
Help to integrate whois Domain Details to website
Hi,
can i know is their any php script r methods to add domain details to my website.
checkbox update
I am having a brain fart right now and i cant remember how to do this. if anyone could help that wou