답변 3개
PHP 에서 int형변환은 intval(문자) 로도 변경합니다.
</span></span></p>
<p><span style="font-size:12pt;"><span style="font-family:맑은 고딕;"><?php </span></span></p>
<p><span style="font-size:12pt;"><span style="font-family:맑은 고딕;">$sum_tot = intval($list[$i]['wr_279']) - intval($list[$i]['wr_353'])+ (intval($list[$i]['wr_181']) - intval($list[$i]['wr223']));</span></span></p>
<p> </p>
<p><span style="font-size:12pt;"><span style="font-family:맑은 고딕;">echo $sum_tot;</span></span></p>
<p> </p>
<p><span style="font-size:12pt;"><span style="font-family:맑은 고딕;">//와 같이 되어야 정상이겠죠</span></span></p>
<p><font face="맑은 고딕"><span style="font-size: 16px;">//그리고</span></font></p>
<p> </p>
<p><font face="맑은 고딕"><span style="font-size: 16px;">$color= "blue";</span></font></p>
<p><font face="맑은 고딕"><span style="font-size: 16px;">if ($sum_tot < 0)</span></font></p>
<p><font face="맑은 고딕"><span style="font-size: 16px;"> $color = "red";</span></font></p>
<p> </p>
<p><font face="맑은 고딕"><span style="font-size: 16px;">$style = "background-color:".$color;</span></font></p>
<p><font face="맑은 고딕"><span style="font-size: 16px;">?></span></font></p>
<p><div style="<?php echo $style?>"></p>
<p>컬러를 적용합니다.</p>
<p></div></p>
<p><span style="font-size:12pt;"><span style="font-family:맑은 고딕;">
이런식으로 하시면 됩니다.
답변에 대한 댓글 3개
참 좋으신 분입니다.
댓글을 작성하려면 로그인이 필요합니다.
계산을 먼저 하시면 됩니다
<?
$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>
댓글을 작성하려면 로그인이 필요합니다.
인라인에 직접하시는거면 스타일에 직접 넣어 주시면 됩니다
style="color:<?php echo (($sum_tot>=0)?"blue":"red");?>;"
답변에 대한 댓글 1개
<span style="font-size:14px; font-weight:bold; color:<?php echo (($sum_tot>=0)?"blue":"red");?>;">
<? echo $sum_tot = $list[$i][wr_279] -$list[$i][wr_353] + $list[$i][wr_181] - $list[$i][wr_223]; ?>
</span>
이렇게 했습니다.
그런데
wr_279: 662
wr_353: 288 (wr_353은 null값이거나 숫자가 있구요,,,어쨌거나)
wr_181: 0
wr_223: 0 값인데
즉 662 -288 +0 -0 = 374 인데
sum_tot가 빨간색으로 출력되어 무엇이 잘못인지 모르겠습니다.
같은 양수인데 파란색으로 출력되는 경우도 있구요,,참 핵갈리네요..
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
그런데
<?php
$sum_tot =
이코드와
컬러를 적용합니다.
<div style="<?php echo $style?>">
<? echo $sum_tot; ?>
</div>
이부분때문에 sum_tot이 두번 출력되고
아래 출력만 백그라운드로 색상이 표시됩니다.
아래거에 백그라운드로 표시되니 원하는대로 되었는데 위에 출력되는 sum_tot는 어떻게 해야 할지요..
즉이렇게 두번 출력됩니다.
127
127 <--이건 백그라운드 적용되었습니다.