관련상품이 없을때 안보이게 하려면?

관련상품이 없을때 안보이게 하려면?

QA

관련상품이 없을때 안보이게 하려면?

본문

item.form.skin 파일에 아래 소스를 삽입하여 관련상품을 불러오고 있는데요.

관련상품이 없을때는 <h1 id="win_title">관련상품</h1> 부분은 안보이게 하고 싶은데,

어떻게 해야 될지 모르겠어요.

도움 부탁 드려요.

 

<h1 id="win_title">관련상품</h1>


    <?php
    $rel_skin_file = $skin_dir.'/'.$default['de_mobile_rel_list_skin'];
    if(!is_file($rel_skin_file))
        $rel_skin_file = G5_MSHOP_SKIN_PATH.'/'.$default['de_mobile_rel_list_skin'];

    $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, 1, 1, $default['de_mobile_rel_img_width'], $default['de_mobile_rel_img_height']);
    $list->set_mobile(true);
    $list->set_query($sql);
    $list->set_view('sns', true);
    echo $list->run();
    ?> 

이 질문에 댓글 쓰기 :

답변 1

관련상품이 있는지 먼저 체크후 출력하시면 됩니다.

아래와 같이 해주세요.


<?php
$tmp = sql_fetch(" select count(*) as cnt 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' ");
if ($tmp['cnt'] > 0) { 
?> 
<h1 id="win_title">관련상품</h1>

    <?php
    $rel_skin_file = $skin_dir.'/'.$default['de_mobile_rel_list_skin'];
    if(!is_file($rel_skin_file))
        $rel_skin_file = G5_MSHOP_SKIN_PATH.'/'.$default['de_mobile_rel_list_skin'];
   
 $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, 1, 1, $default['de_mobile_rel_img_width'], $default['de_mobile_rel_img_height']);
    $list->set_mobile(true);
    $list->set_query($sql);
    $list->set_view('sns', true);
    echo $list->run();
    ?>  
<?php } ?>
 
답변을 작성하시기 전에 로그인 해주세요.
전체 9
QA 내용 검색

회원로그인

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