Ok. Here is the code I have so far...
mysql_query($userrating);
$userratingquery = "SELECT rating FROM user_rating WHERE user_id=$sellerid";
$userrating = mysql_query($userratingquery) or die('SQL Error :: '.mysql_error());
$userrating = array();
while(($row = mysql_fetch_assoc($userrating))) {
$rating[] = $row['rating'];
}
if (!empty($userrating)) {
$averagerating = array_sum($userratingary);
print_r($userratingary);
} else {
echo '<img src="images/star.png" class="ratingstar" /><img src="images/star.png" class="ratingstar" /><img src="images/halfstar.png" class="ratingstar" />';
}
What I'm trying to do is create an array of the database values called "rating", average the values in that array, then I want to round those values up. So, for instance, if the average of those values ends up being 3.7, then the average will then become 4.
From there I can apply the results to the code... I'm just having a lot of trouble with my array right now. The error I'm getting right now is...
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in
Can someone point me in the right direction?