On first sight, and without digging deeper, shouldn't the conditions be $i >=75 and $i >=40? Be aware that there's an undiscriminated gap: e.g. 74.5 won't satisfy any condition and thus might print in green.
Digging just slightly deeper, note that assuming that values in your fields range from 0 through 100, the first if statement test:
if ($i <=75 && $i <=100 )
will be satisfied only by values less than or equal to 75 (which does not seem to meet your conditions for displaying values in red. If I guessed correctly at the output you're getting, you might want to try replacing: