studgate Posted October 20, 2007 Share Posted October 20, 2007 Hi guys, What I am trying to do is echo a variable and use a color depending on the value. <?php switch ($x_active) { case "0": $sTmp = "<blink>NOT ACTIVE</blink>"; break; case "1": $sTmp = "Active"; break; default: $sTmp = ""; } $ox_active = $x_active; $x_active = $sTmp; ?> <?php echo $x_active; ?> <?php $x_active = $ox_active; // Restore original value ?> if it is not active, echo Not active in Red and blinking and if it is active echo it in green. Thanks in advance guys! Quote Link to comment https://forums.phpfreaks.com/topic/74099-solved-help-needed-echo-value-with-color-depending-on-value/ Share on other sites More sharing options...
mattal999 Posted October 20, 2007 Share Posted October 20, 2007 <?php switch ($x_active) { case "0": $sTmp = "<font color='ff0000'><blink>NOT ACTIVE</blink></font>"; break; case "1": $sTmp = "<font color='33ff00'>Active</font>"; break; default: $sTmp = ""; } $ox_active = $x_active; $x_active = $sTmp; ?> <?php echo $x_active; ?> <?php $x_active = $ox_active; // Restore original value ?> Quote Link to comment https://forums.phpfreaks.com/topic/74099-solved-help-needed-echo-value-with-color-depending-on-value/#findComment-374121 Share on other sites More sharing options...
studgate Posted October 20, 2007 Author Share Posted October 20, 2007 that doesn't work. Thanks matta! Quote Link to comment https://forums.phpfreaks.com/topic/74099-solved-help-needed-echo-value-with-color-depending-on-value/#findComment-374128 Share on other sites More sharing options...
mattal999 Posted October 20, 2007 Share Posted October 20, 2007 so, what exactly is the page url, what case are you firing? what does it print? Quote Link to comment https://forums.phpfreaks.com/topic/74099-solved-help-needed-echo-value-with-color-depending-on-value/#findComment-374137 Share on other sites More sharing options...
studgate Posted October 20, 2007 Author Share Posted October 20, 2007 I got it matta, there was only one problem with the color, we didn't use the # character in front. I changed it to: <?php switch ($x_active) { case "0": $sTmp = "<font color='#ff0000'><blink>NOT ACTIVE</blink></font>"; break; case "1": $sTmp = "<font color='#33ff00'>Active</font>"; break; default: $sTmp = ""; } $ox_active = $x_active; $x_active = $sTmp; ?> <?php echo $x_active; ?> <?php $x_active = $ox_active; // Restore original value ?> And it works! Thanks matta Quote Link to comment https://forums.phpfreaks.com/topic/74099-solved-help-needed-echo-value-with-color-depending-on-value/#findComment-374142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.