if 문과 else문으로 글이 없으면 안보이게 처리할려구 합니다.
본문
if 문과 else문으로 글이 없으면 안보이게 처리할려구 합니다.
<?php if( $list['wr_3'] !="") { ?>
<div><span><?php echo $list[$i]['wr_2'] ?></span></div>
<?php } else { ?>
<div><span><?php echo $list[$i]['wr_2'] ?></span></div>
<div><span><?php echo $list[$i]['wr_3'] ?></span></div>
<?php } ?>
리스트에서 위와 같이 처리했는데 wr_3값이 보이네요 ㅠㅠ
!-->답변 2
조건문이 잘못된 것 아닌가요?
if 문 들어갈 때
<?php if( $list['wr_3'] !="") { ?> 이렇게 되어있는데,
먼저는 $list['wr_3'] 이게 아니라 $list[$i]['wr_3'] 이게 맞는 것 아닌가 싶은데요.
그리고 부등호를 저는 != "" 이거 자체가 헷갈리네요;
wr_3이 없으면 wr_2만 출력하는거 아닌가요?
본문대로라면 wr_3이 있을때 wr_2만 출력되고 그게 아닐때 wr_2와 wr_3 가 출력되는군요.
최종적으로
<style>div{background:red} .table_color{background:#ddd !important}</style>
<?php if (!$list[$i]['wr_3']) { ?>
<div><span><?php echo $list[$i]['wr_2'] ?></span></div>
<?php } else { ?>
<div><span><?php echo $list[$i]['wr_2'] ?></span></div>
<div class="table_color"><span><?php echo $list[$i]['wr_3'] ?></span></div>
<?php } ?>
이게 맞는 것 아닐지..
내용이 3이 없으면 2를 보여라
그렇지 않으면
2와 3을 보여라 이니 그렇게 나올듯,,
아래의 3을 지우면 안나올거 같아요