where in 질문입니다

where in 질문입니다

QA

where in 질문입니다

본문


$sql = " select * from {$g5['g5_shop_category_table']} where ca_id in ('101010', '201010') and ca_use = '1' ";

 

list.php(복사본) 23라인 $sql 부분을 위처럼 수정했습니다.

 

제 생각으로는 101010과 201010 제품을 모두 가져와서 그 전체가 섞여서 나올줄 알았는데

101010제품 전체 다음에 201010제품 전체가 나오는듯 하더라구요 (크게 두묶음..?)

order by rand()도 해보았는데 10~이 먼저냐 20~이 먼저냐 차이만 있고 제품들 순서는 그대로 나옵니다.

in을 잘못쓴건지.. sql은 따로 배운 적이 없어서 영카트 쓰면서 구글링으로 쓴게 다라ㅠㅠ

 

10/20구분없이 전부 합쳐져서 나오려면 어떻게 해야할까요?

이 질문에 댓글 쓰기 :

답변 2

/shop/list.php 에서는 카테고리 하나만 지정할 수 있는 구조로 되어있기 때문에..

해당 파일에서는 여러 카테고리의 상품을 불러오는 것이 불가능에 가깝습니다.

 

어떻게 해서든.. 원하는 결과에 가깝게 접근한다면...

sql_fetch() 는 row 하나만 불러오기 때문에.. sql_fetch()를 쓰면 안되고.. 

여러 row를 불러온 후, loop 를 돌리는 방식으로 해야 됩니다. https://sir.kr/qa/245902

 

$sql = " select * from {$g5['g5_shop_category_table']} where ca_id in ('101010', '201010') and ca_use = '1'  ";
$ca = sql_fetch($sql);

->

$sql = " select * from {$g5['g5_shop_category_table']} where ca_id in ('101010', '201010') and ca_use = '1'  ";
$result = sql_query($sql);

$ca = sql_fetch_array($result); // $ca['ca_id] : 101010

 

~

$list = new item_list($skin_file, $ca['ca_list_mod'], $ca['ca_list_row'], $ca['ca_img_width'], $ca['ca_img_height']);
        $list->set_category($ca['ca_id'], 1);
        $list->set_category($ca['ca_id'], 2);
        $list->set_category($ca['ca_id'], 3);
        $list->set_is_page(true);
        $list->set_order_by($order_by);
        $list->set_from_record($from_record);
        $list->set_view('it_img', true);
        $list->set_view('it_id', false);
        $list->set_view('it_name', true);
        $list->set_view('it_basic', true);
        $list->set_view('it_cust_price', true);
        $list->set_view('it_price', true);
        $list->set_view('it_icon', true);
        $list->set_view('sns', true);
        echo $list->run();

 

$ca= sql_fetch_array($result); // $ca['ca_id] : 201010

 

$list = new item_list($skin_file, $ca['ca_list_mod'], $ca['ca_list_row'], $ca['ca_img_width'], $ca['ca_img_height']);
        $list->set_category($ca['ca_id'], 1);
        $list->set_category($ca['ca_id'], 2);
        $list->set_category($ca['ca_id'], 3);
        $list->set_is_page(true);
        $list->set_order_by($order_by);
        $list->set_from_record($from_record);
        $list->set_view('it_img', true);
        $list->set_view('it_id', false);
        $list->set_view('it_name', true);
        $list->set_view('it_basic', true);
        $list->set_view('it_cust_price', true);
        $list->set_view('it_price', true);
        $list->set_view('it_icon', true);
        $list->set_view('sns', true);
        echo $list->run();

 

 

 

 

변경하신 부분은 카테고리 정보를 가져오는 부분입니다.

 

상품을 가져 오는데 필요한 카테고리는

       $list = new item_list($skin_file, $ca['ca_list_mod'], $ca['ca_list_row'], $ca['ca_img_width'], $ca['ca_img_height']);
        $list->set_category($ca['ca_id'], 1);
        $list->set_category($ca['ca_id'], 2);
        $list->set_category($ca['ca_id'], 3);

이 부분에서 정해 줍니다.

 

상품 순서는

/shop/list.php에 보면

    // 상품 출력순서가 있다면
    if ($sort != "")
        $order_by = $sort.' '.$sortodr.' , it_order, it_id desc';
    else
        $order_by = 'it_order, it_id desc';

   ...

        $list->set_order_by($order_by);

 

이런 내용이 있습니다.

순서가 관건이면 상품 정보에서 it_order를 변경해 보세요.

 

그리고 영카트 상품DB 구조 특성상

두 카테고리에 있는 상품을 가져오는 것이 아니고 ( 코드 수정하면 물론 가능합니다.)

특정 카테고리에 나올 상품에 해당 카테고리를 지정하는 방식을 씁니다.

a라는 상품이 카테고리 1010과 2010에 나와야 한다면

a.item.ca_id=1010

a.item.ca_id2=2010

이렇게 지정해 줍니다.

 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 123,523 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT