Jump to content

Adding together values from database


Recommended Posts

$product_id=$_GET['product'];
$sql500="SELECT * FROM $tbl_name3 WHERE product_id='$product_id'";
$result500=mysql_query($sql500);
$num_rows500=mysql_num_rows($result500);
while($row500=mysql_fetch_array($result500)){
extract($row500);
$review_product_rating_total=$review_product_rating; //What do I do here?
}
$average_rating=$review_product_rating_total/$num_rows500;

 

I need a way to take a column of product ratings (0-5 in 1/2 increments), add them together, and divide by the number of rows taken from the database. I know how to get the number of rows with mysql_num_rows. But how would I add together the data from database?

Link to comment
https://forums.phpfreaks.com/topic/236806-adding-together-values-from-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.