if 문과 else문으로 글이 없으면 안보이게 처리할려구 합니다. 채택완료
if 문과 else문으로 글이 없으면 안보이게 처리할려구 합니다.
</p><p><?php if( $list['wr_3'] !="") { ?></p><p style="margin-left: 40px;"><span style="font-size: 11pt; line-height: 1.5;"><div></span><span style="font-size: 11pt; line-height: 1.5;"><span><?php echo $list[$i]['wr_2'] ?></span></span><span style="font-size: 11pt; line-height: 1.5;"></div></span></p><p><span style="font-size: 11pt; line-height: 1.5;"><?php } else { ?></span></p><p style="margin-left: 40px;"><span style="font-size: 14.6667px; line-height: 1.5;"><div></span><span style="font-size: 14.6667px; line-height: 1.5;"><span><?php echo $list[$i]['wr_2'] ?></span></span><span style="font-size: 14.6667px; line-height: 1.5;"></div></span></p><p style="font-size: 14.6667px;"> <span style="font-size: 14.6667px; line-height: 1.5;"><div></span><span style="font-size: 14.6667px; line-height: 1.5;"><span><?php echo $list[$i]['wr_3'] ?></span></span><span style="font-size: 14.6667px; line-height: 1.5;"></div></span> </p><p><?php } ?></p><p>
리스트에서 위와 같이 처리했는데 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 } ?>
이게 맞는 것 아닐지..
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변에 대한 댓글 1개
저도 제 글을 읽어보고 저도 이해가 안되게 글을써서 ㅠㅠ 다시 작성하였습니다.
정말 죄송합니다 ㅠㅠ
[code]
<style>div{background:red} .table_color{background:#ddd !important}</style>
<?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 class="table_color"><span><?php echo $list[$i]['wr_3'] ?></span></div>
<?php } ?>
[/code]
위 처럼 스타일이 지정되어있는 상태인데요.
게시물 1번 은 wr_2과 wr_3 작성하였습니다.
게시물 2번은 wr_2만 작성하였습니다.
근데 게시물 2번은 wr_3을 작성하지 않았는데.
wr_3 영역의 스타일로 지정한 배경색이 그대로 있어서요. ㅠㅠ
번거롭게 하여 죄송합니다. ㅠㅠ
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
더욱더 공부해야되겠습니다 ㅠㅠ
바쁜 시간대에 시간 내주신 두 분께 정말 감사합니다.