This topic is locked
[SOLVED]

 Row color based on cell value

9/23/2009 10:20:12 AM
PHPRunner General questions
B
bedri author

Hello PHPRUNNER
I need to change my row color depending on the value of cell (ex: Status)
The field Status got three values (Open, Pending and Closed) which I assign by a dropdown box when I register a new record into my database;
I would like for Status value = "Open" the whole row to have BLUE color, for Status value = "Pending" the whole row to have RED color and for the Status value = "Closed" some other color.
I have tried this code but it doesn't work

-------------------------------------------------

if ($row["status"] == "open")

{

$status_bkground = "#FF9999";

}

elseif ($row["status"] == "pending")

{

$status_bkground = "#99CCFF";

}

else ($row["status"] == "closed")

{

$status_bkground = "#CCFF99";

}

-------------------------------------------------
I'm looking for some other working code because this one it doesn't fit in my application at all
THANKS PHPRUNNER

J
Jane 9/24/2009

Hi,
please see my changes below:

if ($data["status"] == "open")

{

$row["rowstyle"]='style="background:blue"';

}

elseif ($data["status"] == "pending")

{

$row["rowstyle"]='style="background:red"';

}



Please note field values and names are case sensitive here.

B
bedri author 9/24/2009

Hi Jane,

Thanks for the reply
Can you tell me where to put these lines, I tried in xxx_events.php but it doesn't work.

and this "rowstyle" is it a style that I should apply to my html template page where I can see the changes.
Sorry because I am new in php, and maybe I'm asking something that I shouldn't ..
ok THANKS IN ADVICE;

can you contact me in the_royal007@live.com

J
Jane 9/24/2009

Hi,
you can add this code to the List page: After record processed event on the Events tab.

B
bedri author 9/25/2009

THANKS A LOT...
It did what I needed...
Have Nice Time..

T
thiethie17 10/24/2009

hello phprunners.
how to change the color of the text ??? when the background is dark for example ?
thanks a lot
thiery

J
Jane 10/26/2009

Hi,
here is a sample:

if ($data["status"] == "open")

{

$row["rowstyle"]='style="background:blue; color:white;"';

}