summaryrefslogtreecommitdiffstats
path: root/lib/class/rating.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-27 00:18:59 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-27 00:18:59 +0000
commit6b0b77f12b6873204bfd73a250621115b1f539a0 (patch)
tree36aa24da3e984a3b38e0f1f11fc4a8a2ffdd1973 /lib/class/rating.class.php
parent380a8615ae97295f650699e8ecdf478e54f75d74 (diff)
downloadampache-6b0b77f12b6873204bfd73a250621115b1f539a0.tar.gz
ampache-6b0b77f12b6873204bfd73a250621115b1f539a0.tar.bz2
ampache-6b0b77f12b6873204bfd73a250621115b1f539a0.zip
new coolness from sigger
Diffstat (limited to 'lib/class/rating.class.php')
-rw-r--r--lib/class/rating.class.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index f69e2585..4a513421 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -78,17 +78,19 @@ class Rating {
*/
function get_average() {
- $sql = "SELECT rating FROM ratings WHERE object_id='$this->id' AND object_type='$this->type'";
- $db_results = mysql_fetch_assoc($db_results);
+ $sql = "SELECT user_rating as rating FROM ratings WHERE object_id='$this->id' AND object_type='$this->type'";
+ $db_results = mysql_query($sql, dbh());
$i = 0;
while ($r = mysql_fetch_assoc($db_results)) {
$i++;
- $total = $r['rating'];
+ $total += $r['rating'];
} // while we're pulling results
- $average = floor($total/$i);
+ if ($total > 0) {
+ $average = floor($total/$i);
+ }
$this->rating = $average;