3
Quote:
But with your current code the rating of the article will get lower and lower an lower instead of higher...
function news_updaterating($storyid)
{
global $xoopsDB;
$query = 'SELECT rating FROM '.$xoopsDB->prefix('stories_votedata').' WHERE storyid = '.$storyid;
$voteresult = $xoopsDB->query($query);
$votesDB = $xoopsDB->getRowsNum($voteresult);
$totalrating = 0;
while(list($rating)=$xoopsDB->fetchRow($voteresult)){
$totalrating += $rating;
}
$finalrating = $totalrating; //$votesDB;
$finalrating = number_format($finalrating, 4);
$sql = sprintf("UPDATE %s SET rating = %u, votes = %u WHERE storyid = %u", $xoopsDB->prefix('stories'), $finalrating, $votesDB, $storyid);
$xoopsDB->queryF($sql);
}
Just comment in the $finalrating line where it makes the division and "voila", you have a increasing rating
, if all the points are +1 , the votes and the points are same.
<input type="hidden" name="submit" value="1" />
works fine.. thanks