영카트5에서 상품 카테고리가 나오는부분이요. 채택완료

10년 전 조회 5,067

boxcatecory.skin.php페이지에서 수정하려고 하는데요
여기서 2차카테고리 ca_id가 1010인 상품 페이지에서는 1010, 1020, 1030 등 10으로 시작되는 상품카테고리만 나오게 하려면 어떻게 해야하나요..?
현재 2차카테고리가 먼저 오고 마우스오버 했을 때 3차카테고리가 나오게 수정을 했습니다


<nav id="gnb">
    <h2>쇼핑몰 카테고리</h2>
    <ul id="gnb_1dul">
        <?php
        // 1단계 분류 판매 가능한 것만
        $hsql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where length(ca_id) = '4' and ca_use = '1' order by ca_order, ca_id ";
        $hresult = sql_query($hsql);
        $gnb_zindex = 999; // gnb_1dli z-index 값 설정용
        for ($i=0; $row=sql_fetch_array($hresult); $i++)
        {
            $gnb_zindex -= 1; // html 구조에서 앞선 gnb_1dli 에 더 높은 z-index 값 부여
            // 2단계 분류 판매 가능한 것만
            $sql2 = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where LENGTH(ca_id) = '6' and SUBSTRING(ca_id,1,4) = '{$row['ca_id']}' and ca_use = '1' order by ca_order, ca_id ";
            $result2 = sql_query($sql2);
            $count = mysql_num_rows($result2);
        ?>
        <li class="gnb_1dli" style="z-index:<?php echo $gnb_zindex; ?>">
            " class="gnb_1da<?php if ($count) echo ' gnb_1dam'; ?>"><?php echo $row['ca_name']; ?>
            <?php
            for ($j=0; $row2=sql_fetch_array($result2); $j++)
            {
            if ($j==0) echo '<ul class="gnb_2dul" style="z-index:'.$gnb_zindex.'">';
            ?>
                <li class="gnb_2dli">/list.php?ca_id=<?php echo $row2['ca_id']; ?>" class="gnb_2da"><?php echo $row2['ca_name']; ?></li>
            <?php }
            if ($j>0) echo '</ul>';
            ?>
        </li>
        <?php } ?>
    </ul>
</nav>


여기서 2차카테고리 ca_id가 1010인 상품 페이지에서는 1010, 1020, 1030 등 10으로 시작되는 상품카테고리만 나오게 하려면 어떻게 해야하나요..?​ 

답변 1개

채택된 답변
+20 포인트


<?php

&nbsp; &nbsp; &nbsp; $ca_id_j = substr($ca_id,0,2);



&nbsp; &nbsp; &nbsp; &nbsp; // 1단계 분류 판매 가능한 것만

&nbsp; &nbsp; &nbsp; &nbsp; $hsql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where length(ca_id) = '4' and ca_use = '1' and ca_id like '$ca_id_j%' order by ca_order, ca_id ";

&nbsp; &nbsp; &nbsp; &nbsp; $hresult = sql_query($hsql);

&nbsp; &nbsp; &nbsp; &nbsp; $gnb_zindex = 999; // gnb_1dli z-index 값 설정용

&nbsp; &nbsp; &nbsp; &nbsp; for ($i=0; $row=sql_fetch_array($hresult); $i++)

&nbsp; &nbsp; &nbsp; &nbsp; {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $gnb_zindex -= 1; // html 구조에서 앞선 gnb_1dli 에 더 높은 z-index 값 부여

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 2단계 분류 판매 가능한 것만

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $sql2 = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where LENGTH(ca_id) = '6' and SUBSTRING(ca_id,1,4) = '{$row['ca_id']}' and ca_use = '1' order by ca_order, ca_id ";

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result2 = sql_query($sql2);

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $count = mysql_num_rows($result2);

&nbsp; &nbsp; &nbsp; &nbsp; ?>



이렇게해보세요
로그인 후 평가할 수 있습니다

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

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

로그인
🐛 버그신고