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)? Quote Link to comment Share on other sites More sharing options...
.josh Posted March 28, 2011 Share Posted March 28, 2011 $result * 20 Quote Link to comment 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; Quote Link to comment 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 Quote Link to comment 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.