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

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

QA

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

답변 2

본문

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>

 

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 129,119
© SIRSOFT
현재 페이지 제일 처음으로