Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

영카트4 상품상세 페이지 관련 상품 출력

2009-07-29 by 편리

영카트4로 만들어진 쇼핑몰에 상품마다 관련 상품을 등록하는 것은 아무래도 비능률적인 일인 것 같아서 약간의
꼼수를 부려서 같은 카테고리내 상품 중에서 상품코드 번호를 기준으로 전 후로 몇개의 상품이 출력되도록 수정을
해봤다. it_opt1 이라는 필드에 상품코드를 입력했기 때문에 이것을 기준으로 정렬이 되도록 수정을 했다.

<!– 관련상품 출력(JAG몰 추가) –>
 <tr>
    <td height=”100″ valign=”top”>
        <?
            $sql_1 = ” select * from $g4[yc4_item_table] where it_opt1 < ‘$it[it_opt1]’ and ca_id = ‘$ca_id’ and it_use = ‘1’ order by it_opt1 desc “;
            $sql_2 = ” select * from $g4[yc4_item_table] where it_opt1 > ‘$it[it_opt1]’ and ca_id = ‘$ca_id’ and it_use = ‘1’ order by it_opt1 asc “;             
             
            $result_1 = sql_query($sql_1);
            $num_1 = @mysql_num_rows($result_1);
            $result_2 = sql_query($sql_2);
            $num_2 = @mysql_num_rows($result_2);

            if($num_1 < 6) $num_2 = 12 – $num_1;
            if($num_2 < 6) $num_1 = 12 – $num_2;
            if($num_1 >= 6 && $num_2 >= 6) $num_1 = $num_2 = 6;           
           
            $sql = ” ( select * from $g4[yc4_item_table] where it_opt1 < ‘$it[it_opt1]’ and ca_id = ‘$ca_id’ and it_use = ‘1’ order by it_opt1 desc limit $num_1 ) union ( select * from $g4[yc4_item_table] where it_opt1 > ‘$it[it_opt1]’ and ca_id = ‘$ca_id’ and it_use = ‘1’ order by it_opt1 asc limit $num_2 ) order by it_opt1 desc “;

            $list_mod   = $default[de_rel_list_mod];
            $img_width  = $default[de_rel_img_width];
            $img_height = $default[de_rel_img_height];
            $td_width = (int)(100 / $list_mod);

            $result = sql_query($sql);
            $num = @mysql_num_rows($result);
            if ($num)
            include “$g4[shop_path]/maintype10.inc.php”;
            else
            echo “이 상품과 관련된 상품이 없습니다.”;           
        ?>
    </td>
</tr>

항상 그렇지만 코드는 완전 지저분하다. 특정 상품 전 후로 상품 코드를 불러서 정렬을 해야하기 때문에 sql 쿼리를
두번 시도해야하는데.. 이거 한번에 할 수 있으면 좋겠는데.. ㅋ 그래서 union 명령을 이용해서 다른 두 개의 쿼리
결과값을 하나로 합친 후 이것을 내림차순을 정렬해서 출력이 되도록 했다. 영카트4의 기분 기능을 이용하기 때문에
적용에 크게 문제는 없을 것이라 생각이 된다. itemp.php 파일을 수정하면 된다. 제대로 한 건지 모르겠다. ^^;

Post navigation

Previous Post:

조금은 체하기도 하는거지

Next Post:

코딩을 조금 했네

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • SK 세븐모바일 유심 셀프교체
  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes