Guest User

Untitled

a guest
Oct 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. // Bayesian Rating Calc
  2. $theItem = $_GET[’id’];
  3. if($theItem) {
  4. // all items votes and ratings
  5. $result = mysql_query(”SELECT AVG(item),AVG(vote) FROM itemvotes WHERE vote>0′ GROUP BY item”) or die(mysql_error());
  6. $row = mysql_fetch_row($result);
  7. $avg_num_votes = $row[0];
  8. $avg_rating = $row[1];
  9.  
  10. // this item votes and ratings
  11. $result = mysql_query(”SELECT COUNT(item),AVG(vote) FROM itemvotes WHERE item=$theItem’ AND vote>0′”) or die(mysql_error());
  12. $row2 = mysql_fetch_row($result);
  13. $this_num_votes = $row2[0];
  14. $this_rating = $row2[1];
  15.  
  16. if(!$row OR !$row2)
  17. $br = “_”;
  18. else
  19. $br = number_format( ((($avg_num_votes * $avg_rating) + ($this_num_votes * $this_rating))/($avg_num_votes + $this_num_votes)), 1,.);
  20. } // end of if item selected
Add Comment
Please, Sign In to add comment