jarv Posted August 27, 2015 Share Posted August 27, 2015 Hi, I am trying to add values together in my while loop, so far I have: $q->query($DB, $SQL); while($avrating=$q->getrow()): $averageratings = $avrating['sum(rating)'] / $noofreviews; $overallaverage = round($averageratings, 2) + round($averageratings, 2); echo '<p>'.$avrating['rating_name'].': '.round($averageratings, 2).'</p>'; endwhile; echo 'x'.$overallaverage; $overallaverage += $overallaverage / 10; echo 'The Average: '.$overallaverage; from this, I get: x7.34The Average: 8.074 the total shold be: 42.34 then dived by 10 should be 4.23 Quote Link to comment https://forums.phpfreaks.com/topic/297951-adding-values-in-a-while-loop/ Share on other sites More sharing options...
Barand Posted August 27, 2015 Share Posted August 27, 2015 $q->query($DB, $SQL); What is the query that is being executed? Quote Link to comment https://forums.phpfreaks.com/topic/297951-adding-values-in-a-while-loop/#findComment-1519730 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.