Please help me make an image change color based on an external database number!

hi all-

i need help with making an (1) image change colors based on a number from a database. for example if the number is 1 then the image is yellow, 2= orange, 3=red, and so forth.

please help me with this if you can or at least lead me in the right direction.

-thank you