색상 표현
본문
<? echo $sum_tot = (int)$list[$i][wr_279] - (int)$list[$i][wr_353] + ( (int)$list[$i][wr_181] - (int)$list[$i][wr_223] ); ?>
위의 sum_tot이 양수이면 blue색으로 음수이면 red색으로 출력하려는데 도와주십시오..
늘 미안합니다. 비슷한 거는 해봤는데 막상 이상황에서 하려니 잘 안되는군요,
답변 3
PHP 에서 int형변환은 intval(문자) 로도 변경합니다.
<?php
$sum_tot = intval($list[$i]['wr_279']) - intval($list[$i]['wr_353'])+ (intval($list[$i]['wr_181']) - intval($list[$i]['wr223']));
echo $sum_tot;
//와 같이 되어야 정상이겠죠
//그리고
$color= "blue";
if ($sum_tot < 0)
$color = "red";
$style = "background-color:".$color;
?>
<div style="<?php echo $style?>">
컬러를 적용합니다.
</div>
이런식으로 하시면 됩니다.
인라인에 직접하시는거면 스타일에 직접 넣어 주시면 됩니다
style="color:<?php echo (($sum_tot>=0)?"blue":"red");?>;"
계산을 먼저 하시면 됩니다
<?
$sum_tot = $list[$i][wr_279] -$list[$i][wr_353] + $list[$i][wr_181] - $list[$i][wr_223];
?>
<span style="font-size:14px; font-weight:bold; color:<?php echo (($sum_tot>=0)?"blue":"red");?>;">
<?php echo $sum_tot;?>
</span>