0){ while($data = mysql_fetch_assoc($sel)){ $total = $data['totalvotepoints']; $divident = $data['totalvotes']; $rows++; } if($divident == 0) { return '0%'; }else{ $perc = ($total/$divident) * 20; } //$newPerc = round($perc/5)*5; //return $newPerc.'%'; //$newPerc = round($perc,2); return $perc.'%'; } else { return '0%'; } } function outOfFive($id){ $total = 0; $rows = 0; $sel = mysql_query("SELECT totalvotepoints,totalvotes FROM games WHERE gameid = '$id'") or die(mysql_error()); if(mysql_num_rows($sel) > 0){ while($data = mysql_fetch_assoc($sel)){ $total = $data['totalvotepoints']; $divident = $data['totalvotes']; $rows++; } if($divident == 0) { return '0'; }else{ $perc = ($total/$divident); return round($perc,2); //return round(($perc*2), 0)/2; // 3.5 } } else { return '0'; } } function getVotes($id){ $sel = mysql_query("SELECT totalvotes FROM games WHERE gameid = '$id'") or die(mysql_error()); $rows = mysql_fetch_assoc($sel); if($rows[totalvotes] == 0){ $votes = '0 Votes'; } else if($rows[totalvotes] == 1){ $votes = '1 Vote'; } else { $votes = $rows[totalvotes].' Votes'; } return $votes; } function pullRating($id,$show5 = false, $showPerc = false, $showVotes = false, $static = NULL){ global $rewrite; // Check if they have already voted... $text = ''; $alreadyrated = $_COOKIE['rated']; if((strpos($alreadyrated, "|$id|")!==false) || ($static == 'novote')){ if($show5 || $showPerc || $showVotes){ $text .= '
'; } if($show5){ $text .= 'Rated '.outOfFive($id).'/5'; } if($showPerc){ $text .= ' ('.getRating($id).')'; } if($showVotes){ $text .= ' ('.getVotes($id).')'; } if($show5 || $showPerc || $showVotes){ $text .= '
'; } return $text.'
'; } else { if($show5 || $showPerc || $showVotes){ $text .= '
'; } if($show5){ $show5bool = 'true'; $text .= 'Rated '.outOfFive($id).'/5'; } else { $show5bool = 'false'; } if($showPerc){ $showPercbool = 'true'; $text .= ' ('.getRating($id).')'; } else { $showPercbool = 'false'; } if($showVotes){ $showVotesbool = 'true'; $text .= ' ('.getVotes($id).')'; } else { $showVotesbool = 'false'; } if($show5 || $showPerc || $showVotes){ $text .= '
'; } if($rewrite == 1) { return $text.'
'; }else{ return $text.'
'; } //------------- } } // Added in version 1.5 // Fixed sort in version 1.7 function getTopRated($limit, $table, $idfield, $namefield){ $result = ''; $sql = "SELECT COUNT(ratings.id) as rates,ratings.rating_id,".$table.".".$namefield." as thenamefield,ROUND(AVG(ratings.rating_number),2) as rating FROM ratings,".$table." WHERE ".$table.".".$idfield." = ratings.rating_id GROUP BY rating_id ORDER BY rates DESC,rating DESC LIMIT ".$limit.""; $sel = mysql_query($sql); $result .= ''."\n"; return $result; } ?>