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

for문에 ul넣기 채택완료

아무거나만들었어요 9년 전 조회 5,117

<div class="lt" data="464">

            

            

    <strong class="lt_title"><a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $bo_table ?>"></a></strong>

    <ul class="menus">

    <?php for ($i=0; $i<count($list); $i++) {

      

if(!$list[$i]['wr_reply']){

if($reply_cnt){

echo "<a class='show_line top se".$list[$i]['wr_id']." re".$list[$i]['wr_num']."' onclick='showoff(".$list[$i]['wr_num'].")'><p>▶</p></a>";

}

echo "<li class='top' onclick='showRe(".$list[$i]['wr_id'].")'><a data='\"".$list[$i]['wr_id']."\"' target='iframe_show' id='latest_st' href=\"".$list_href."\">";

    echo "&nbsp;&nbsp;&nbsp;&nbsp;".$list[$i]['subject']."&nbsp;".$reply_cnt."";

    echo "</a></li>";

}

}      

    ?>

             <?php

            //답변글만 출력

            

            if($list[$i]['wr_reply']){

            if($reply_cnt_re){

            echo "<a class='show_line_re  se".$list[$i]['wr_id']."  re".$list[$i]['wr_num']." ce".$list[$i]['wr_1']."'   onclick='showoff_re(".$list[$i]['wr_id'].")'><p>▶</p></a>";

            }

            echo "<li class=' se".$list[$i]['wr_1']." re".$list[$i]['wr_num']." ce".$list[$i]['wr_1']." re'  onclick='showRe_re(".$list[$i]['wr_id'].")'>";

            if($reply_cnt_re){

            echo "<a data='\"".$list[$i]['wr_id']."\"' class='font_re' target='iframe_show'  id='latest_re' href=\"".$re_list_href."\" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$list[$i]['icon_reply']."&nbsp;&nbsp;";

            }else{

            echo "<a data='\"".$list[$i]['wr_id']."\"' class='font_re' target='iframe_show'  id='latest_re'  href=\"".$list[$i]['href']."\" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$list[$i]['icon_reply']."&nbsp;&nbsp;";

            }

            echo $list[$i]['subject']."&nbsp;&nbsp;".$reply_cnt_re."";

            echo "</a></li>";

            }

            }

            ?>

    <?php }  ?>기

    </ul>

 

현재 이렇게 최신글이 설정되어있습니다.

현재 이 소스로 출력을 하게 되면 모든 글들이 li로 감싸서 출력이 되게 해놨기때문에

소스검사시

 

 

<li>1<li>

<li>1-1<li> 

<li>1-2<li> 

<li>1-3<li> 

 

이렇게 단계가 없이 모두 li로 실행이 되는 상태가 됩니다.

 

제가 하고싶은건 저기 위의 답변글 소스 부분에 ul을 넣어서 같은 값을 가지는 답변글들은 한묶음을하고싶은데 li바로앞에 ul을 붙이면 

<li>1<li>

<ul><li>1-1<li></ul> 

<ul><li>1-2<li></ul> 

<ul><li>1-3<li></ul> 

for문 때문에 이렇게 되더라구요 ㅜㅜㅜ

 

<li>1<li>

<ul>

<li>1-1<li> 

<li>1-2<li> 

<li>1-3<li>

</ul>

 

이렇게 하는 방법이 있을까요 ??

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

답변 2개

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

질문에 대한 답변은 아니지만 위의 구조는 아래처럼 하셔야...

ul 하위에 li, li 하위에 다시 ul이 들어가도록요~

 

</p><p><ul class='main'> 
    <li>
        1
        <ul class='sub'>
            <li>1-1</li> 
            <li>1-2</li> 
            <li>1-3</li> 
        </ul>
    </li>
</ul></p><p>
 

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

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

9년 전

<li>1<li>

<ul>

<li>1-1<li> 

<li>1-2<li> 

<li>1-3<li>

</ul>

 

이 구조 자체가 비정상입니다.... 차라리 원하는 형태를 그림으로 라도 보여주시는게 이해하기가 쉽지않을까요 ?

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

답변에 대한 댓글 2개

아무거나만들었어요
9년 전
<ul class='main'>
<li>1<li>
<ul class='sub'>
<li>1-1<li>
<li>1-2<li>
<li>1-3<li>
</ul>
</ul>


이렇게 되어있는 상태가 비정상인가요???
왕계란
9년 전
<table>
<tr>
<td></td>
<table><tr><td>dd</td></tr></table>
</tr>
</table>
지금 코딩하신 게 이렇게 되어 있는 거라 보시면 됩니다.

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

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

로그인