There is just a small problem with the comparison logic, since 1 > 0, just like 1002 > 0, any positive integer will make the first if clause true. As such, start with a comparison against the greatest possible value instead.
And, stick to the same comparison operator all the way, in this case >. In your example above you switched from > to < in the middle.
Also, since the ; is not part of the color, I'd leave it out of it. That is, instead of assigning strings like "#123456;" I'd just assign "#123456" and add the ; as needed in the inline style attribute.
# Any value less than 40k goes on to the next if
if ($defwin >= 40000)
$color = "#000000";
# Any value less than 30k goes on to the next if. Any value of 40k or higher was dealt with above
# so this part is only true for values from 30000 to 39999
else if ($defwin >= 30000)
$color = "#993300";
/* and continue in this way until you get to the compaison against your lowest value */
elseif ($defwin >= 0)
$color = "#FFFFFF";
echo '<table><tbody><tr>';
echo "<td style=\"background-color:$color; color:#ff0000; font-size:12; font-weight:bold;\">".$defwin."</td>";
echo '</tr></tbody></table>';