Jump to content

[SOLVED] Help Needed: Echo value with color depending on value.


studgate

Recommended Posts

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!

Link to comment
Share on other sites

<?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 ?>

Link to comment
Share on other sites

;D 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  :D

Link to comment
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.