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!

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

;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

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.