The Little Guy Posted March 28, 2011 Share Posted March 28, 2011 I can't remember the math to do this, but I use MySQL to calculate an average: 5 = 100% 0 = 0% I want to make a bar that shows an average (like a bar graph) so lets say I get 2.5 as one of my returned results, that means the bar should only be 50% long of the maximum width. Using calculations, how can I get the number 50 (the max width is 100% of a table cell)? Link to comment https://forums.phpfreaks.com/topic/231910-get-averageratio/ Share on other sites More sharing options...
.josh Posted March 28, 2011 Share Posted March 28, 2011 $result * 20 Link to comment https://forums.phpfreaks.com/topic/231910-get-averageratio/#findComment-1193102 Share on other sites More sharing options...
jcbones Posted March 28, 2011 Share Posted March 28, 2011 $used = 2.5; $total = 5; $percent = number_format(($used * 100) / $total); echo $percent; Link to comment https://forums.phpfreaks.com/topic/231910-get-averageratio/#findComment-1193108 Share on other sites More sharing options...
The Little Guy Posted March 28, 2011 Author Share Posted March 28, 2011 sweet! that seems to work! Thanks Link to comment https://forums.phpfreaks.com/topic/231910-get-averageratio/#findComment-1193116 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.