foreach 문에서 개수 조절 방법 좀 알려 주세요
본문
메인화면에 겔러리 최신글을 불러오는데
아래 소스로는 최신글 5개가 불려오는데 최신글 2개만 불러 올려면 어떻게 해야 할까요
제가 아직 초보라
누가 좀 알려줘요 ~~~~~~
부탁해요 ~~~~~~
<? if(count($gallery_list)): ?>
<? foreach($gallery_list as $lt): ?>
<p class="s2" style="left: 0px;">
<table width="320" border=0 cellspacing=0 cellpadding=0 valign="top"><tr><td valign="top">
<a href="<?=URL_DIR ?>/board/view/?category=<?=$lt -> category ?>&code=<?=$lt -> code ?>&page=<?=$this -> page ?><?=$this -> params ?>">
<img src="/data/<?=$lt -> fk_name . '/' . $lt -> category . '/' . $lt -> thumb_name ?>" alt="<?=$lt -> title ?>" title="<?=$lt -> title ?>" width="130" height="90"/>
</a>
</td>
<td valign="top" align="right">
<a href="/board/view/?category=gallery&code=<?= $lt -> code ?>" class="substr" style="width:160px;">
<? if($lt->summary_name != NULL) : ?>
<span class="<?= $lt -> summary_color ?>_t">[<?= $lt -> summary_name ?>]</span>
<? endif; ?>
<?
if ($lt -> comment_cnt) :
echo character_limiter($lt -> title, 35) . ' (' . $lt -> comment_cnt . ')';
else :
echo character_limiter($lt -> title, 35);
endif;
if (substr($lt -> write_date, 0, 10) == date("Y-m-d")) :
echo " <img src='/images/user/new_main.gif' alt='gallery'>";
endif;
?>
</a><p>
<span class="year"><?=substr($lt -> write_date, 0, 10) ?></span>
</td><td width="20"><!----간격 띄우기----></td></tr></table>
</p>
<? endforeach; ?>
<? else: ?>
<? endif; ?>