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
Menu restriction
How can I restrict the individual menu that would appear when a user logs in so that all users are c
get multiple rows
Hi I want to get multiple rows from a db
I am using this for the db query
Code: public
Server side $_SESSION
how does one keep the session completely server side. no cookies to the browser at all. i need this
Calculating n! using vector
#include
#include
#include
using
Post PHP form to non-existing page
The company that I work for host their PHP code on IIS on a Windows server, no Apache, so no mod_rew
classic dynpro : hide area and auto adjust hights
Hi,
I want to develop a similar user interface as is used in standard transaction MIGO.
mail() says sent but no email received
My code is quite simple:
Code: <?php
$to = "Ty44ler@yahoo.com";
$subje
php file erros / need help please
Hello
Someone decoded a zend file for me.. after uploaded it on ftp i get some errors, i trye
Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.
What I'm doin
convert static html data into dynamic
hi all
i need to convert a website which has static above 2000 articles into dynamic and add