리스트 페이지에서 첨부 파일 반복문으로 불러오기입니다.

리스트 페이지에서 첨부 파일 반복문으로 불러오기입니다.

QA

리스트 페이지에서 첨부 파일 반복문으로 불러오기입니다.

답변 3

본문

리스트 페이지에서 첨부파일을 아래 소스 처럼 불러오게 되면 첨부파일 갯수를 일정하게 해야되는데
반복문으로 해서 첨부된 파일들만 불러오게 하고 싶습니다.
초보자라 반복문으로 만들기가 쉽지가 않습니다.
혹시 가능하신분 알려주시면 정말 감사하겠습니다.
 


                <?php if ($is_good) { ?><li><span class="gall_subject">추천</span><strong><?php echo $list[$i]['wr_good'] ?></strong></li><?php } ?>
                <?php if ($is_nogood) { ?><li><span class="gall_subject">비추천</span><strong><?php echo $list[$i]['wr_nogood'] ?></strong></li><?php } ?>
            </ul>
        </li>
<!-- 여기서 부터 반복문 시작 -->
<div style="display: none;"> 
  <a href="<?echo $list[$i]['file'][1]["path"]."/".$list[$i]['file'][1]["file"];?>"></a>
 
  <a href="<?echo $list[$i]['file'][2]["path"]."/".$list[$i]['file'][2]["file"];?>"></a>
  <a href="<?echo $list[$i]['file'][3]["path"]."/".$list[$i]['file'][3]["file"];?>"></a>
</div>
<!-- 여기가 반복문 끝 -->

        <?php } ?>
        <?php if (count($list) == 0) { echo "<li class=\"empty_list\">게시물이 없습니다.</li>"; } ?>
    </ul>

이 질문에 댓글 쓰기 :

답변 3


<!-- 여기서 부터 반복문 시작 -->
<div style="display: none;">
    <a href="<?echo $list[$i]['file'][1]["path"]."/".$list[$i]['file'][1]["file"];?>"></a>
    <a href="<?echo $list[$i]['file'][2]["path"]."/".$list[$i]['file'][2]["file"];?>"></a>
  <a href="<?echo $list[$i]['file'][3]["path"]."/".$list[$i]['file'][3]["file"];?>"></a>
</div>
<!-- 여기가 반복문 끝 -->

 

위의 코드라고 인식하고 

 


<!-- 여기서 부터 반복문 시작 -->
<div style="display: none;">
   <?php
        for ($j = 1; $j <= 3; $j++) {
             if ($list[$i]['file'][$j]['file']) {  ?>
                 <a href="<?echo $list[$i]['file'][$j]['path']."/".$list[$i]['file'][$j]['file'];?>"><?php echo $list[$i]['file'][$j]['file'];?></a>
             <?php } 
        }
    ?>
</div>
<!-- 여기가 반복문 끝 -->

<!-- 여기서 부터 반복문 시작 -->
<div style="display: none;"> 
<?php for($j = 1; $j <= count($list[$i]['file']); $j++) { ?>
    <a href="<?php echo $list[$i]['file'][$j]["path"]."/".$list[$i]['file'][$j]["file"];?>"></a>
<?php } ?>
</div>
<!-- 여기가 반복문 끝 -->

두분 답변 감사드립니다.
그림자 밟기님 소스로는 원래 첨부 파일보다 빈값으로 2개가 더 생기네요.
플래토님 소스로 정확하게 첨부파일 갯수 만큼 나타납니다.
두분 모두 감사드립니다.

 

 

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