i want to compare a number in 3 areas
for example:
when $a is > 0 and < 80 echo RED
when $a is > 80 and < 100 echo YELLOW
when $a is > 100 echo RED
the problem with my code now is: when $a=80 i got no result
here is my code:
<?php
$a=80;
if(($a > 0) && ($a < 80))
{
echo('RED');
}
if(($a > 80) && ($a < 100))
{
echo('YELLOW');
}
if($a > 100)
{
echo('GREEN');
}
?>
you can see the test with $a=79 here
and with $a=80 here
how can i realize this? maybe in a smaller and nicer way 😀
don’t know if it’s important.. but $a can be 80.1 and can be bigger than 100
You need to determine which color you want
80to be. in this example I’ll make itREDDo you notice the
=in$a <= 80Additionally, you will run into the same problem with
100and0so you will need to deal with those as well.