include("includes/rating_config.php"); /* Dynamic Star Rating Redux Developed by Jordan Boesch www.boedesign.com Licensed under Creative Commons - http://creativecommons.org/licenses/by-nc-nd/2.5/ca/ Used CSS from komodomedia.com. */ function getRating($id){ $total = 0; $rows = 0; $sel = mysql_query("SELECT rating_num FROM ratings WHERE rating_id = '$id'"); if(mysql_num_rows($sel) > 0){ while($data = mysql_fetch_assoc($sel)){ $total = $total + $data['rating_num']; $rows++; } $perc = ($total/$rows) * 20; //$newPerc = round($perc/5)*5; //return $newPerc.'%'; $newPerc = round($perc,2); return $newPerc.'%'; } else { return '0%'; } } function outOfFive($id){ $total = 0; $rows = 0; $sel = mysql_query("SELECT rating_num FROM ratings WHERE rating_id = '$id'"); if(mysql_num_rows($sel) > 0){ while($data = mysql_fetch_assoc($sel)){ $total = $total + $data['rating_num']; $rows++; } $perc = ($total/$rows); return round($perc,2); //return round(($perc*2), 0)/2; // 3.5 } else { return '0'; } } function getVotes($id){ $sel = mysql_query("SELECT rating_num FROM ratings WHERE rating_id = '$id'"); $rows = mysql_num_rows($sel); if($rows == 0){ $votes = '0 Votes'; } else if($rows == 1){ $votes = '1 Vote'; } else { $votes = $rows.' Votes'; } return $votes; } function pullRating($id,$show5 = false, $showPerc = false, $showVotes = false, $static = NULL){ // Check if they have already voted... $text = ''; $sel = mysql_query("SELECT id FROM ratings WHERE IP = '".$_SERVER['REMOTE_ADDR']."' AND rating_id = '$id'"); if(mysql_num_rows($sel) > 0 || $static == 'novote' || isset($_COOKIE['has_voted_'.$id])){ if($show5 || $showPerc || $showVotes){ $text .= '