for문 관련 질문드립니다. 채택완료
둠둠
8년 전
조회 1,998
$thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $imgwidth, $imgheight);
if($thumb['src']) {
$img_content = '';
} else {
$img_content = 'NO IMAGE';
}
echo $img_content; ?>
=$list[$i]['subject']?>
=$list[$i]['wr_content']?>
latest부분인데요
보시다시피 li가 for문 안에서 돌아가고 있습니다
저기에 li class="MAR0" 로 해놨는데
총 4개가 메인에 나오는데
앞에 3개의 li는 class없이
마지막 li에만 class를 넣고 싶습니다.
어떻게 작성해주어야하는지 궁금합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
채택된 답변
+20 포인트
8년 전
</p><p><?php for ($i=0; $i<count($list); $i++) { </p><p><span style="white-space: pre; color: rgb(255, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">if($i == 3){</span></p><p><span style="white-space: pre; color: rgb(255, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">$style = "MAR0";</span></p><p><span style="white-space: pre; color: rgb(255, 0, 0);"> </span><span style="color: rgb(255, 0, 0);">}</span></p><p>?><span style="white-space:pre"> </span></p><p><span style="white-space:pre"> </span><li class="<span style="color: rgb(255, 0, 0);"><? echo $style; ?></span>"></p><p><span style="white-space:pre"> </span><a href="<?php echo $list[$i]['href'] ?>"></p><p><span style="white-space:pre"> </span><p></p><p><span style="white-space:pre"> </span><?php </p><p><span style="white-space:pre"> </span>$thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $imgwidth, $imgheight);</p><p><span style="white-space:pre"> </span>if($thumb['src']) {</p><p><span style="white-space:pre"> </span>$img_content = '<img src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'">';</p><p><span style="white-space:pre"> </span>} else {</p><p><span style="white-space:pre"> </span>$img_content = 'NO IMAGE';</p><p><span style="white-space:pre"> </span>} </p><p><span style="white-space:pre"> </span>echo $img_content;<span style="white-space:pre"> </span> <span style="white-space:pre"> </span>?></p><p><span style="white-space:pre"> </span></p></p><p><span style="white-space:pre"> </span><p class="subject"><?=$list[$i]['subject']?></p></p><p><span style="white-space:pre"> </span><p class="content"><?=$list[$i]['wr_content']?></p><span style="white-space:pre"> </span></p><p><span style="white-space:pre"> </span></a></p><p><span style="white-space:pre"> </span></li> </p><p><?php } ?></p><p>
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
�
둠둠
8년 전
흐어 감사합니다.
댓글을 작성하려면 로그인이 필요합니다.
8년 전
</p><p>
</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><?php</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">$chk = 3; // 넣고싶은 순번 0~3 인경우 4번째</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"> for ($i=0; $i<count($list); $i++) { <span style="font-size: 14.004px;">?></span><span style="font-size: 14.004px; white-space: pre;"> </span></p><p style="margin-left: 40px; word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><li <?php if(chk ==$i){ echo "<span style="font-size: 14.004px;">class='MAR0'";}?>></span></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span><a href="<?php echo $list[$i]['href'] ?>"></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span><p></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span><?php </p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span>$thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $imgwidth, $imgheight);</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span>if($thumb['src']) {</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span>$img_content = '<img src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'">';</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span>} else {</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span>$img_content = 'NO IMAGE';</p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span>} </p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span>echo $img_content;<span style="white-space: pre;"> </span> <span style="font-size: 11pt; white-space: pre;"> </span><span style="font-size: 11pt;">?></span></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span></p></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span><p class="subject"><?=$list[$i]['subject']?></p></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span><p class="content"><?=$list[$i]['wr_content']?></p><span style="white-space: pre;"> </span></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="white-space: pre;"> </span></a></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="font-size: 11pt; white-space: pre;"> </span><span style="font-size: 11pt;"></li></span> </p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><?php } ?></p><p style="word-break: break-all; color: rgb(72, 72, 72); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
�
둠둠
8년 전
답변 감사합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인