Jump to content

formatting numbers in different colors


blackholesun

Recommended Posts

Hi all,

 

If anyone can offer any advice on the following, that would be great... I've been running round in circles on the internet trying to find this answer but am having no success...

 

All i want to be able to do is to format a MySQL query result so that a negative number is red and a positive number is blue. So far, the query runs fine, the results are displayed largely in the format i want, i am just trying to do this one last refinement. I'm thinking something along the lines of:

if($row['number'] < 0){
//display red
}else{
//display blue
}

...but what i have attempted with that conditional will not write to the table output. I'm probably barking up the wrong tree with the if..else conditional but am still new to php so am having trouble coming up with the right solution. So, is there a way of doing this just with php? Or am I going to have to use something else?

 

Any help/info greatly appreciated :)

Link to comment
https://forums.phpfreaks.com/topic/278081-formatting-numbers-in-different-colors/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.