미채택 완료

좌측메뉴 활성화

2019-01-08 (화) 08:52:13 2,614

좌측메뉴는 잘나오고 있는데요.

게시판 활성화시 해당 메뉴 색깔을 바꿀려고 합니다.

좌측메뉴 코드는 아래와 같고요.

Copy
<?php
        $tmp_code = substr($me_code,0,2);
        $tmp_menu_name=sql_fetch(" select * from {$g5['menu_table']} where me_use = '1' and length(me_code) = '2' and me_code = '$tmp_code' ");
        ?>

            <h2><?=$tmp_menu_name['me_name']?></h2>
        <?

        $sql2 = " select *
                    from {$g5['menu_table']}
                    where me_use = '1'
                      and length(me_code) = '4'
                      and substring(me_code, 1, 2) = '$tmp_code'
                    order by me_order,me_code, me_id ";
        $result2 = sql_query($sql2);

        for ($k=0; $row2=sql_fetch_array($result2); $k++) {
            if($k == 0)
                echo '<ul class="snb_2dul">'.PHP_EOL;
        ?>
            <li class="snb_2dli">
                <a href="<?php echo $row2['me_link']; ?>" target="_<?php echo $row2['me_target']; ?>" class="snb_2da <?php if($row2['me_code']==substr($me_code,0,4)) { echo "on"; }?>"><?php echo $row2['me_name'] ?></a>
        <?php

            //3차메뉴 불러 오기.
            $sql3 = " select *
                        from {$g5['menu_table']}
                        where me_use = '1'
                          and length(me_code) = '6'
                          and substring(me_code, 1, 4) = '{$row2['me_code']}'
                        order by me_order,me_code, me_id ";
            $result3 = sql_query($sql3);
            $num3 = sql_num_rows($result3);
            if($num3>0){
                echo '<ul class="snb_3dul">'.PHP_EOL;
                while($row3=sql_fetch_array($result3)){
        ?>
                    <li class="snb_3dli">
                        <a href="<?php echo $row3['me_link']; ?>" target="_<?php echo $row3['me_target']; ?>" class="snb_3da <?php if($row3['me_code']==$me_code) { echo "on2"; }?>">-&nbsp;&nbsp;<?php echo $row3['me_name'] ?></a>
                    </li>
        <?php
                }
                echo '</ul>'.PHP_EOL;
            }
            echo '</li>'.PHP_EOL;                   

        }

        if($k > 0)
            echo '</ul>'.PHP_EOL;
        ?>

코드중에서

if($row2['me_code']==substr($me_code,0,4)) { echo "on"; }

if($row3['me_code']==$me_code) { echo "on2"; }

두가지가 작동하지 않는 이유를 모르겠습니다.

고수님들 답변좀 부탁드립니다.

|

답변 1개

2019-01-08 (화) 09:12:08

해결했습니다. 정상작동합니다.

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