Hi,
Pl. see this snippet of code. One of the variables can either be a negative or a positive number.
My problem is that if the number is negative , I want it to be in red. How do I code it please ?
The code works perfectly.
Thanks.Swati
<td><b><font face="Tahoma" size="2" color="#800080">Deviation %</b></td>
// other rows like above and then rest of code
$bval = $myrow3["BValue"];
$diff = $ocval - $bval;
if ($diff > 0)
{
$dev = round( ($diff/$bval)*100, 2 );
}
else
{
$diff = abs($diff);
$dev = - round( ($diff/$bval)*100, 2 );// put a minus sign if its a negative deviation
}
}
printf("<tr>
<td><input type=\"radio\" name=\"choice\" value=\"%d\"></td>
<td><font face=Tahoma size=2 color=#800080>%s</td>
<td><font face=Tahoma size=2 color=#800080> %s </td>
<td><font face=Tahoma size=2 color=#800080> %s </td>
<td><font face=Tahoma size=2 color=#800080> %s </td>
<td><font face=Tahoma size=2 color=#800080> %s </td>
<td><font face=Tahoma size=2 color=#800080> %s </td>
</tr>",
$myrow["Oid"],
$myrow["Comp"],
$myrow["name"],
$New,
calculatedate($myrow["date"]) ,
$enq,
$dev ); // this number should be in red if its negative
?>