aboutsummaryrefslogtreecommitdiffstats
path: root/include/ws_functions.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/ws_functions.inc.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 68e90f81a..04e0dbbf3 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -781,14 +781,20 @@ SELECT id, name, permalink, uppercats, global_rank, commentable
$related_tags[$i]=$tag;
}
//------------------------------------------------------------- related rates
- $query = '
+ $rating = array('score'=>$image_row['average_rate'], 'count'=>0, 'average'=>null);
+ if (isset($rating['score']))
+ {
+ $query = '
SELECT COUNT(rate) AS count
, ROUND(AVG(rate),2) AS average
FROM '.RATE_TABLE.'
WHERE element_id = '.$image_row['id'].'
;';
- $rating = pwg_db_fetch_assoc(pwg_query($query));
- $rating['count'] = (int)$rating['count'];
+ $row = pwg_db_fetch_assoc(pwg_query($query));
+ $rating['score'] = (float)$rating['score'];
+ $rating['average'] = (float)$row['average'];
+ $rating['count'] = (int)$row['count'];
+ }
//---------------------------------------------------------- related comments
$related_comments = array();