게시판 가로로 두줄출력하는법좀요.. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

게시판 가로로 두줄출력하는법좀요.. 정보

게시판 가로로 두줄출력하는법좀요..

본문

게시판 가로로 두줄출력할라고 세시간째 검색해보고 고민중인데 안되네요 ㅠㅠ
<?

//기본값 설정
$save_w = $board[bo_1]; //썸네일넓이
$save_h = $board[bo_2];  //썸에일높이

for ($i=0; $i<count($list); $i++) {
        $bg = $i%2 ? 0 : 1;
    ?>

이부분을어떻게 건들면될거같은데..

<table width="<?=$width?>" align="center" cellpadding="0" cellspacing="0"><tr><td>

    <!-- 분류 셀렉트 박스, 게시물 몇건, 관리자화면 링크 -->
    <div class="board_top">
        <div style="float:left;">
            <form name="fcategory" method="get" style="margin:0px;">
            <? if ($is_category) { ?>
            <select name=sca onchange="location='<?=$category_location?>'+<?=strtolower($g4[charset])=='utf-8' ? "encodeURIComponent(this.value)" : "this.value"?>;">
            <option value=''>전체</option>
            <?=$category_option?>
            </select>
            <? } ?>
            </form>
        </div>
        <div style="float:right;">
            <img src="<?=$board_skin_path?>/img/icon_total.gif" align="absmiddle" border='0'>
            <span style="color:#888888; font-weight:bold;">Total <?=number_format($total_count)?></span>
            <? if ($rss_href) { ?><a href='<?=$rss_href?>'><img src='<?=$board_skin_path?>/img/btn_rss.gif' border='0' align="absmiddle"></a><?}?>
            <? if ($admin_href) { ?><a href="<?=$admin_href?>"><img src="<?=$board_skin_path?>/img/btn_admin.gif" border='0' title="관리자" align="absmiddle"></a><?}?>
        </div>
    </div>

    <!-- 제목 -->
    <form name="fboardlist" method="post">
    <input type='hidden' name='bo_table' value='<?=$bo_table?>'>
    <input type='hidden' name='sfl'  value='<?=$sfl?>'>
    <input type='hidden' name='stx'  value='<?=$stx?>'>
    <input type='hidden' name='spt'  value='<?=$spt?>'>
    <input type='hidden' name='page' value='<?=$page?>'>
    <input type='hidden' name='sw'  value=''>

    <table cellspacing="0" cellpadding="0" class="board_list">
    <? if ($is_checkbox) { ?><col width="40" /><? } ?>
<col width="110" />
    <col width="150" />
<col />
    <col width="100" />
    <tr>
        <td colspan='<?=$colspan?>' height="1" style="border-bottom:1px dotted #ddd;"></td>
    </tr>


    <?

//기본값 설정
$save_w = $board[bo_1]; //썸네일넓이
$save_h = $board[bo_2];  //썸에일높이

for ($i=0; $i<count($list); $i++) {
        $bg = $i%2 ? 0 : 1;
    ?>




    <tr class="bg<?=$bg?>">
    <? if ($is_checkbox) { ?><td class="checkbox"><input type=checkbox name=chk_wr_id[] value="<?=$list[$i][wr_id]?>"></td><? } ?>

<td align="center"><?=$list[$i][wr_2]?><br><?=$list[$i][wr_1]?><br><b><?=$list[$i][wr_subject]?></b></td>

        <td>
<?if($list[$i][file][0][file]!=''){?>
<img src="<?=$g4[path]?>/data/file/<?=$bo_table?>/<?=$list[$i][file][0][file]?>" width="<?=$save_w?>" height="<?=$save_h?>">
<?}else{?>
<img src="<?=$board_skin_path?>/img/noimg.gif" width="<?=$save_w?>" height="<?=$save_h?>">
<?}?>
</td>

        <td>
            <?
            echo "<a href='{$list[$i][href]}'>".cut_str($list[$i][wr_content],200,'...')."</a>";
            ?>
        </td>
<td><?=$list[$i][wr_4]?></td>

    </tr>
    <? } // end for ?>

    <? if (count($list) == 0) { echo "<tr><td colspan='$colspan' height=100 align=center>게시물이 없습니다.</td></tr>"; } ?>


    </table>
 
제가검색해서 찾아본결과
아래소스
<?
$list[]='상품1';
$list[]='상품2';
$list[]='상품3';
$list[]='상품4';
$list[]='상품5';
?>
<table border=1>
<?
for($i=0; $i<count($list); $i+=2){?>
<tr><td><?=$list[$i]?></td>
    <td><?if($list[$i+1]) echo $list[$i+1]; else echo "&nbsp;"?></td>
</tr>
<?}?>
</table>

를 어떻게 수정하면될거같은데 .. ㅠㅠ 너무어렵네됴
  • 복사

댓글 전체

검색해서 찾은 방법대로 하자면
$list 갯수가 홀수개일 때 처리가 있어야 하고 좌우 내용출력 부분을 두번 코딩 해야겠죠

수학적인간단한 논리가 좀 있어야 하는 문제입니다
아래처럼 하면 됩니다

$cnt= ceil( count($list)/2);
 for($k=0; $k< $cnt; $k++){
 $bg = $k%2 ? 0 : 1;
 echo "<tr class='bg$bg'>";
 for($h=0; $h< 2; $h++){  $i= $k *2 + $h;
  if(!$list[$i][wr_id]){?>
  <? if ($is_checkbox) echo "<td>&nbsp;</td>"; ?>
  <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
  <?} else{?>
  <? if ($is_checkbox) <--여기부터 원래 코드
 ~
~
 <td><?=$list[$i][wr_4]?></td> <--여기까지
<?}
} //for h
echo "</tr>";
} //for k
?>
답변감사드립니다. ^^ ㅠ 그런데 저코드를 어디다가 넣어야하는지 모르겠습니다.
//기본값 설정
$save_w = $board[bo_1]; //썸네일넓이
$save_h = $board[bo_2];  //썸에일높이

for ($i=0; $i<count($list); $i++) {
        $bg = $i%2 ? 0 : 1;
    ?>
요 밑으로넣어야하나요?? 제가하니까 오류만뜨네요 ㅠ
에쿠, 코드를 다 만들어줘도 적용을 못한다면 홈페이지를 원하는대로 만든다는 것은..

for ($i=0; $i<count($list); $i++) {  <-- 여기부터

<-- 여기 까지를 완전히 바꾸는 겁니다
</table>
감사합니다 ^^

    <?

//기본값 설정
$save_w = $board[bo_1]; //썸네일넓이
$save_h = $board[bo_2];  //썸에일높이

for ($i=0; $i<count($list); $i++) {
      $cnt= ceil( count($list)/2);
 for($k=0; $k< $cnt; $k++){
 $bg = $k%2 ? 0 : 1;
 echo "<tr class='bg$bg'>";
 for($h=0; $h< 2; $h++){  $i= $k *2 + $h;
  if(!$list[$i][wr_id]){?>
  <? if ($is_checkbox) echo "<td>&nbsp;</td>"; ?>
  <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
  <?} else{?>

    <? if ($is_checkbox) { ?><td class="checkbox" colspan='<?=$colspan?>'><input type=checkbox name=chk_wr_id[] value="<?=$list[$i][wr_id]?>"></td><? } ?>
<tr>
<td align="left" colspan='<?=$colspan?>'>

<span style="font-size:12pt;"><b><?=$list[$i][wr_2]?><?=$list[$i][wr_1]?><?=$list[$i][wr_subject]?></b></font></td>
</tr>
        <td width="200" >
<?if($list[$i][file][0][file]!=''){?>
<img src="<?=$g4[path]?>/data/file/<?=$bo_table?>/<?=$list[$i][file][0][file]?>" width="<?=$save_w?>" height="<?=$save_h?>">
<?}else{?>
<img src="<?=$board_skin_path?>/img/noimg.gif" width="<?=$save_w?>" height="<?=$save_h?>">
<?}?>
</td>

        <td height="200">
            <?
            echo "".get_text($list[$i][wr_content],200,'...')."</a>";
            ?>


        </td>

<td><?=$list[$i][wr_4]?></td>
<?}
} //for h
echo "</tr>";
} //for k
?>


    </table>
요렇게 코딩을 했는데 게시판이 아예안뜨네요 .ㅠㅠ 저혼자해보려고하는데 생각되로 되질안네요.
더 고민해보겠습니다.
답변감사드립니다.~
© SIRSOFT
현재 페이지 제일 처음으로