javascript - Changing background color of td based on php array value -


with below code trying change background color of td element. think code needs correction, please. it's not applying color. or other better solution.

php code:

$color = "#000000"; if (($change[array_keys($change)[0]] < 0)) $color = "#e54028";     else if (($change[array_keys($change)[0]] >= 1) && ($change[array_keys($change)[0]] <= 19))        $color = "#f18d05";     else if ($change[array_keys($change)[0]] >= 20)        $color = "#61ae24"; 

td element:

<td <?php echo "style=background: $color";?>><?php echo $change[array_keys($change)[0]];?>%</td> 

table after wangjie code

hm, did tried this? https://www.w3schools.com/cssref/pr_background-color.asp

<?php echo "style='background-color:{$color};' "; ?> 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -