I have the following code:
<div style='width:635px;height:20px;'>
<div style='float:left;margin-top:1px;margin-bottom:1px;width:".$neg."%;height:18px;background-color: #BF4F4C;'></div>
<div style='float:left;margin-top:1px;margin-bottom:1px;width:".$pass."%;height:18px;background-color: #E37A0D;'></div>
<div style='float:left;margin-top:1px;margin-bottom:1px;width:".$pos."%;height:18px;background-color: #9ABB59;'></div>
</div>
You can see that the '%' is a PHP variable - due to rounding, sometimes this equates to 101% and then the final bar is placed underneath the preceding two and not next to. Anyway to stop this?
Fiddle: http://jsfiddle.net/jVter/
PHP:
$pos = number_format(($row[1]/$row[0])*100,0);
$pass = number_format(($row[2]/$row[0])*100,0);
$neg = number_format(($row[3]/$row[0])*100,0);
Further code (this is a multi-query):
SELECT COUNT( ". $r ." ) AS Total,
(SELECT COUNT( ". $r ." ) FROM tresults WHERE ". $r ." >=750) AS Engaged,
(SELECT COUNT( ". $r ." ) FROM `tresults` WHERE ". $r ." >=450 AND ". $r ." <=749) AS Passive,
(SELECT COUNT( ". $r ." ) FROM `tresults` WHERE ". $r ." <=449) AS Disengaged
FROM `tresults`