HDFilmMaker2112 Posted May 19, 2011 Share Posted May 19, 2011 $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 More sharing options...
HDFilmMaker2112 Posted May 19, 2011 Author Share Posted May 19, 2011 $total = $total + $review_product_rating; Link to comment https://forums.phpfreaks.com/topic/236806-adding-together-values-from-database/#findComment-1217321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.