<?php
$pre_toid = explode("?id=", $_SERVER['HTTP_REFERER']);
$toid = $pre_toid[1];
$result = mysql_query("SELECT * FROM `hub` where to_id='".$toid."'");
$nvotes=mysql_num_rows($result);
while($row=mysql_fetch_array($result)) {
$dbratings = $row["rating"];
$votes_array = array("votes" => $dbratings);
}
$added_votes = array_sum($votes_array);
$divided_votes = $added_votes/$nvotes;
$total_rating = $divided_votes;
?>
Ok, I got that far, but there is something wrong with the while loop. When I try and print or add the array it only prints or gets the sum of one vote from the array, and I know for a fact that there are at least 30 entries in the table.