특정 상품의 주문 건수 개수를 가져오려고 합니다. 채택완료

특정 상품의 주문 건수 개수를 불러와 뿌려주려고 하는데, 아래를 어떻게 변경하면 될까요?

Copy
<?php            
            $sql  = " SELECT COUNT(IF($it[it_id], it_id, NULL)) FROM `g5_shop_cart` WHERE 1";
            $result = sql_query($sql);
            $output = mysql_num_rows($result);
            echo $output    ?>

답변 2개

채택된 답변
+20 포인트

$sql = "select count(*) as cnt from g5_shop_cart where it_id = '{$it[it_id]}'";

$res = sql_fetch($sql);

echo $res[cnt];

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

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

$row = sql_fetch("select count(*) as cnt from g5_shop_cart where it_id = '$it_id' and ct_status<>'취소' and ct_status<>'쇼핑' and ct_status<>'삭제' ");

echo $row['cnt'];

 

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

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

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

로그인
🐛 버그신고