Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bayesian Rating Calc
- $theItem = $_GET[’id’];
- if($theItem) {
- // all items votes and ratings
- $result = mysql_query(”SELECT AVG(item),AVG(vote) FROM itemvotes WHERE vote>’0′ GROUP BY item”) or die(mysql_error());
- $row = mysql_fetch_row($result);
- $avg_num_votes = $row[0];
- $avg_rating = $row[1];
- // this item votes and ratings
- $result = mysql_query(”SELECT COUNT(item),AVG(vote) FROM itemvotes WHERE item=’$theItem’ AND vote>’0′”) or die(mysql_error());
- $row2 = mysql_fetch_row($result);
- $this_num_votes = $row2[0];
- $this_rating = $row2[1];
- if(!$row OR !$row2)
- $br = “_”;
- else
- $br = number_format( ((($avg_num_votes * $avg_rating) + ($this_num_votes * $this_rating))/($avg_num_votes + $this_num_votes)), 1, ‘.’ );
- } // end of if item selected
Add Comment
Please, Sign In to add comment