테스트 사이트 - 개발 중인 베타 버전입니다

리스트에 여분필드 출력(값이 없는것 출력하지 않습니다.) 채택완료

연탄집개 8년 전 조회 4,662

여분필드는 

<span class="fz_gallery_content">대지위치 : <?php echo $list[$i]['wr_1'] ?></span>

이렇게 출력하면 되는데 wr_1번에 값이 없으면 출력이 않되도록 하려고 합니다.


어떻게 처리해야 하는지요? 


감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
8년 전

1. wr_1값이 없으면 span 태그까지 숨기기

</p><p><?php if ($list[$i]['wr_1']==TRUE){?></p><p><span class="fz_gallery_content">대지위치 : <?php echo ($list[$i]['wr_1']) ?></span></p><p><?php } ?></p><p>


2. 값만 숨기기

</p><p><span class="fz_gallery_content">대지위치 : <?php  echo ($list[$i]['wr_1']==TRUE)?$list[$i]['wr_1']:""; ?></span>
</p><p>

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

안녕하세요. 인아이디어입니다.<br />
<br />
<div class="code-block-wrapper">
<button onclick="copyCodePrism(this)" class="copy-code-btn" style="position: absolute; top: 10px; right: 10px; z-index: 10; background: rgba(0,0,0,0.5); color: #fff; border: 1px solid rgba(255,255,255,0.3); padding: 6px 12px; border-radius: 4px; font-size: 12px; cursor: pointer; transition: all 0.2s; backdrop-filter: blur(10px);" onmouseover="this.style.background='rgba(0,0,0,0.7)'; this.style.transform='translateY(-1px)'" onmouseout="this.style.background='rgba(0,0,0,0.5)'; this.style.transform='translateY(0)'">
<svg style="width: 14px; height: 14px; display: inline-block; vertical-align: middle; margin-right: 4px;" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
</svg>
<span class="copy-text">Copy</span>
</button>
<pre class="language-php"><code class="language-php">&lt;?php

if (!empty($list[$i][&#039;wr_1&#039;])) {

echo &#039;&lt;span class=&quot;fz_gallery_content&quot;&gt;대지위치 : &#039;.$list[$i][&#039;wr_1&#039;].&#039;&lt;/span&gt;&#039;;

}

?&gt;</code></pre>
</div><br />
<br />
이렇게 처리하시면 될것같습니다.
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인