Jump to content

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 :)

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.