필드가 빈칸일때 출력하지 않는방법 문의드립니다.

필드가 빈칸일때 출력하지 않는방법 문의드립니다.

QA

필드가 빈칸일때 출력하지 않는방법 문의드립니다.

본문

write.php 에서 wr_1 ~ wr_10까지 필드가 들어있는 상태이고

list.php 에서 wr_1 ~ wr_10까지 필드가 출력되게 만들어놨는데요.

wr_9 또는 wr_10 필드가 빈칸일때

list.php 에서 출력하지 않게 할 수 있는 방법이 있을까요?

 

list.php에서 보여지는건 테이블 형식으로 보여집니다.

wr_9 와 wr_10의 필드가 빈칸인경우 비어있는 테이블은 출력하지 않게 하고 싶습니다.

 

<div class="table-responsive">
  <table class="table">
    <thead>
      <tr>
        
        <th scope="col">Cat.No.</th>
        <th scope="col">Size</th>

      </tr>
    </thead>
    <tbody>
      <tr>
        
        <td><?php echo strip_tags($list[$i][wr_1], "<br>");?></td>
        <td><?php echo strip_tags($list[$i][wr_2], "<br>");?></td>

      </tr>
      <tr>
        
        <td><?php echo strip_tags($list[$i][wr_3], "<br>");?></td>
        <td><?php echo strip_tags($list[$i][wr_4], "<br>");?></td>

      </tr>
      <tr>
        
        <td><?php echo strip_tags($list[$i][wr_5], "<br>");?></td>
        <td><?php echo strip_tags($list[$i][wr_6], "<br>");?></td>

      </tr>

      <tr>
        
        <td><?php echo strip_tags($list[$i][wr_7], "<br>");?></td>
        <td><?php echo strip_tags($list[$i][wr_8], "<br>");?></td>

      </tr>

      <tr>
        
        <td><?php echo strip_tags($list[$i][wr_9], "<br>");?></td>
        <td><?php echo strip_tags($list[$i][wr_10], "<br>");?></td>

      </tr>      
    </tbody>
  </table>
</div>

이 질문에 댓글 쓰기 :

답변 2

비어있는 테이블을 출력하지 않게 하고싶다 -> <table>...</table>을 출력하지 않는다 라면
<table> 앞에 조건을 주면 되지 않을까요?

 

<div class="table-responsive">

<?php if(!empty($list[$i][wr_9]) || !empty($list[$i][wr_10])) { ?>

  <table class="table">

<!-- 테이블 내용 -->
  </table>

<?php } ?>
</div>

 

답변을 작성하시기 전에 로그인 해주세요.
전체 215
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT