如何根据.php文件中的值更改值的背景颜色?
问题描述:
I have a line of code that currently works like this:
$dimension = '<span style="background-color: #FFFF00"> T='.$thickness.'</span> X='.$x.' Y='.$y;
As you can see the value $thickness
Is highlighted yellow. However $thickness
is a value that changes to the following values: 1.90, 1.50, and 1.15.
How would I make each value have it's own background color?
Example= 1.90 = Yellow, 1.50 = Green, 1.15 = Blue.
答
$color = 'white';
if($thickness > 1.15) { $color = 'blue'; }
if($thickness > 1.5) { $color = 'green'; }
if($thickness > 1.9) { $color = 'yellow'; }
$dimension = '<span style="background-color: '.$color.'"> T='.$thickness.'</span> X='.$x.' Y='.$y;