채택완료

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

2015-09-11 (금) 19:46:08 2,898

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개 / 댓글 2개

채택된 답변
+20 포인트

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

아래와 같이 해주세요.

Copy
<?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 } ?>
 

답변에 대한 댓글 2개

아주 잘됩니다.~ㅎ
감사합니다.히힛.
꼭 필요해서 검색하다가 덕분에 해결 했습니다. ^^
감사합니다.

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