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
Displaying a clickable playername
I am going wrong somewhere with the mysql_query, can someone please put me straight?
$playern
How to make a mail Form secure?
I want to create an email Form on my web site. How can I make the Form secure so the submitted info
Making multiple rows with one query
I have a table called efed_handler_characters with two fields handler_id and bio_id. What query 2 is
Greek characters in php
Hi,
I'm making a script and I m using for first time greek characters.
I started to write
Problem in back link
I have page where i have given javascript back link but when i click on it browser give a message
Curly Bracket Delimeters.
I'd always believed that the starting and ending delimeters in preg_ functions had to be the same ch
How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy
Doubles are giving me problems
Ok so, first of all i made a double = 0.05, but when running the debugger it shows up as 0.04999. I
Creating an invoice
Using fpdf I am trying to create an invoice to send to clients. The products are sold in pricing tie
How would I do "Users not logged in since *** delete them"
I know how I would set this up, and delete the user roughly.
I'll create a table called "Use