Also, any idea why this code isn't working? I thought it was the same code I was using before, but reviews stick at the rating of the first review, and don't alter when new reviews are added.
Quote:
// if we're approved, update the product count & average review, and user's review count
if(!$vbulletin->options['prodforums_appreviews'])
{
$ratings = $db->query_first_slave("SELECT rating FROM "
. TABLE_PREFIX
. "pf_review WHERE productid = "
. $db->escape_string($vbulletin->GPC['productid']) );
$new_rating = (array_sum($ratings)/((count($ratings)*5))*100);
$db->query_write("UPDATE "
. TABLE_PREFIX
. "pf_product SET rating = "
. $new_rating
.", reviews = reviews + 1 WHERE productid = '"
. $db->escape_string($vbulletin->GPC['productid']) ."'");
}
|