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

영카트 관련상품 질문입니다. 채택완료

마주닝 3년 전 조회 3,258

</p>

<p><?php if ($default['de_rel_list_use']) { ?>

<!-- 관련상품 시작 { -->

<section id="sit_rel">

    <h2>관련상품</h2>

    <?php

    $rel_skin_file = $skin_dir.'/'.$default['de_rel_list_skin'];

    if(!is_file($rel_skin_file))

        $rel_skin_file = G5_SHOP_SKIN_PATH.'/'.$default['de_rel_list_skin'];</p>

<p>    $sql = " select b.* from {$g5['g5_shop_item_relation_table']} a left join {$g5['g5_shop_item_table']} b on (a.it_id2=b.it_id) where a.it_id = '{$it['it_id']}' and b.it_use='1' ";

    $list = new item_list($rel_skin_file, $default['de_rel_list_mod'], 0, $default['de_rel_img_width'], $default['de_rel_img_height']);

    $list->set_query($sql);

    echo $list->run();

    ?>

</section>

<!-- } 관련상품 끝 -->

<?php } ?></p>

<p>

 

 관련상픔을

전체상품 랜덤출력으로 변경하고 싶습니다 ㅠ ㅠ

전체상품 불러오는 쿼리로 리미트 걸어서 6개 정도 출력하면 될것 같은데

sql 쪽은 배우는 단계라 답이 안보이네요 ㅠㅠㅠ

염치 불구하고 도움을 청해봅니다 ㅠㅠㅠ

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

답변 1개

채택된 답변
+20 포인트
플라이
3년 전
select b.* from {$g5['g5_shop_item_relation_table']} a left join {$g5['g5_shop_item_table']} b on (a.it_id2=b.it_id) where a.it_id = '{$it['it_id']}' and b.it_use='1' order by rand() limit 6;

 

위 쿼리 부분을 수정해 적용해 주시면 상품은 랜덤으로 가져오고 6개까지만 가져오게 될겁니다.

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

답변에 대한 댓글 3개

마주닝
3년 전
관련상품을 가져오는게 아닌 사이트 내 전체상품을 가져오려면 어떻게 해야할까요 ㅠㅠ
플라이
3년 전
select * from {$g5['g5_shop_item_table']} where it_id = '{$it['it_id']}' and it_use='1' order by rand() limit 6

이렇게 하시면 전체 상품을 가져옵니다.
마주닝
3년 전
select * from {$g5['g5_shop_item_table']} where it_use='1' order by rand() limit 6
요렇게 하니깐 되네요!!
감사합니다!!

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

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

로그인