장바구니에서 브랜드명 출력문제..돠주세요 ㅇ ㅠㅠ

장바구니에서 브랜드명 출력문제..돠주세요 ㅇ ㅠㅠ

QA

장바구니에서 브랜드명 출력문제..돠주세요 ㅇ ㅠㅠ

본문

장바구니에서 브랜드명이 출력되게 할방법이 없을까요?

 

 



for ($i=0; $row=sql_fetch_array($result); $i++)
{
    // 합계금액 계산
    $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
                    SUM(ct_point * ct_qty) as point,
                    SUM(ct_qty) as qty
                from {$g5['g5_shop_cart_table']}
                where it_id = '{$row['it_id']}'
                  and od_id = '$s_cart_id' ";
    $sum = sql_fetch($sql);

    if ($i==0) { // 계속쇼핑
        $continue_ca_id = $row['ca_id'];
    }

    $a1 = '<a href="'.shop_item_url($row['it_id']).'" class="prd_name"><b>';
    $a2 = '</b></a>';
    $image = get_it_image($row['it_id'], 80, 80);

    $it_name = $a1 . stripslashes($row['it_name']) . $a2;
    $it_brand = $a1 . stripslashes($row['it_brand']) . $a2;  //손본부분..
    $it_options = print_item_options($row['it_id'], $s_cart_id); 
    if($it_options) {
        $mod_options = '<div class="sod_option_btn"><button type="button" class="mod_options">선택사항수정</button></div>';
        $it_name .= '<div class="sod_opt">'.$it_options.'</div>';

    }

    // 배송비
    switch($row['ct_send_cost'])
    {
        case 1:
            $ct_send_cost = '착불';
            break;
        case 2:
            $ct_send_cost = '무료';
            break;
        default:
            $ct_send_cost = '선불';
            break;
    }

    // 조건부무료
    if($row['it_sc_type'] == 2) {
        $sendcost = get_item_sendcost($row['it_id'], $sum['price'], $sum['qty'], $s_cart_id);

        if($sendcost == 0)
            $ct_send_cost = '무료';
    }

    $point      = $sum['point'];
    $sell_price = $sum['price'];
?>

<tr>
    <td class="td_chk chk_box">
        <input type="checkbox" name="ct_chk[<?php echo $i; ?>]" value="1" id="ct_chk_<?php echo $i; ?>" checked="checked" class="selec_chk">
       <label for="ct_chk_<?php echo $i; ?>"><span></span><b class="sound_only">상품</b></label>
    </td>

    <td class="td_prd">
        <div class="sod_img"><a href="<?php echo shop_item_url($row['it_id']); ?>"><?php echo $image; ?></a></div>

        <div class="sod_name">

            <input type="hidden" name="it_id[<?php echo $i; ?>]" value="<?php echo $row['it_id']; ?>">
            <input type="hidden" name="it_name[<?php echo $i; ?>]" value="<?php echo get_text($row['it_name']); ?>">

            <?php echo $it_brand.$it_name.$mod_options; ?>   //손본부분..


        </div>

 

 

제가 해본부분을

//손본부분이라고 표시했어요

그런데 브랜드명이 출력이 안되는데 ㅠㅠ

뭐가 문제인가요?

 

 

$sql = " select a.ct_id,
                a.it_id,
                a.it_name,
                a.ct_price,
                a.ct_point,
                a.ct_qty,

 

 

이부분에다가도 a.it_brand를 추가했는데 에러가나는데 도와주실분 계신가요 ㅠ

이 질문에 댓글 쓰기 :

답변 1

위의 나열한 코드보다 좀더 상단영역 쿼리에서

it_brand를 추가해야 

아래 추가한 코드들이 작동합니다.

 


 
// $s_cart_id 로 현재 장바구니 자료 쿼리
$sql = " select a.ct_id,
                a.it_id,
                a.it_name,
                a.ct_price,
                a.ct_point,
                a.ct_qty,
                a.ct_status,
                a.ct_send_cost,
                a.it_sc_type,
                b.ca_id,
                b.ca_id2,
                b.ca_id3,
                b.pt_it,
                b.pt_msg1,
                b.pt_msg2,
                b.pt_msg3
                , b.it_brand  --브랜드추가
           from {$g5['g5_shop_cart_table']} a left join {$g5['g5_shop_item_table']} b on ( a.it_id = b.it_id )
          where a.od_id = '$s_cart_id' ";
$sql .= " group by a.it_id ";
$sql .= " order by a.ct_id ";
$result = sql_query($sql);
 
// 이하 질문한 영역

와우.. 감동입니다!! 한방에 해결됐어요 전 b.it_brand가 아니고 a.it_brand로 했더니 안먹던데..
이거 워크벤치가서 확인해야하는건가요? 테이블이름인가용?ㅠㅠ완전초짜라서 ㅠㅠ감사합니다..

from {$g5['g5_shop_cart_table']} a left join {$g5['g5_shop_item_table']} b
를 보시면
table alias 를 cart를 a 로
shop_item 을 b로
alias가 되어있는것을 보고
it_brand는 item에 들어있는 값이라서
join을 해서 값을 가져올때 해당테이블의 정보를 가져와야죠

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

회원로그인

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