상품 판매 랭킹에서 월간 판매량 랭킹으로 출력하려 합니다.
어디를 어떻게 수정해야 될까요?
아래 소스입니다.
<?
if ($sort1 == "") $sort1 = "ct_status_sum";
if ($sort2 == "") $sort2 = "desc";
$sql = " select a.it_id,
b.*,
SUM(IF(ct_status = '쇼핑',ct_qty, 0)) as ct_status_1,
SUM(IF(ct_status = '주문',ct_qty, 0)) as ct_status_2,
SUM(IF(ct_status = '준비',ct_qty, 0)) as ct_status_3,
SUM(IF(ct_status = '배송',ct_qty, 0)) as ct_status_4,
SUM(IF(ct_status = '완료',ct_qty, 0)) as ct_status_5,
SUM(IF(ct_status = '취소',ct_qty, 0)) as ct_status_6,
SUM(IF(ct_status = '반품',ct_qty, 0)) as ct_status_7,
SUM(IF(ct_status = '품절',ct_qty, 0)) as ct_status_8,
SUM(ct_qty) as ct_status_sum
from $g4[yc4_cart_table] a, $g4[yc4_item_table] b ";
$sql .= " where a.it_id = b.it_id and b.it_type1 = '1' ";
$sql .= " group by a.it_id
order by $sort1 $sort2 ";
$result = sql_query($sql);
?>
<table cellpadding=0 cellspacing=0 width=100%>
<tr><td colspan=20 height=3 bgcolor=#0E87F9></td></tr>
<tr align=center class=ht>
<td width=50>순위</td>
<td width=80></td>
<td width=''>상품명</td>
<td width=50><a href='<?=title_sort("ct_status_1",1)."&$qstr1"?>'>쇼핑</a></td>
<td width=50><a href='<?=title_sort("ct_status_2",1)."&$qstr1"?>'>주문</a></td>
<td width=50><a href='<?=title_sort("ct_status_3",1)."&$qstr1"?>'>준비</a></td>
<td width=50><a href='<?=title_sort("ct_status_4",1)."&$qstr1"?>'>배송</a></td>
<td width=50><a href='<?=title_sort("ct_status_5",1)."&$qstr1"?>'>완료</a></td>
<td width=50><a href='<?=title_sort("ct_status_6",1)."&$qstr1"?>'>취소</a></td>
<td width=50><a href='<?=title_sort("ct_status_7",1)."&$qstr1"?>'>반품</a></td>
<td width=50><a href='<?=title_sort("ct_status_8",1)."&$qstr1"?>'>품절</a></td>
<td width=50><a href='<?=title_sort("ct_status_sum",1)."&$qstr1"?>'>합계</a></td>
</tr>
<tr><td colspan=20 height=1 bgcolor=#CCCCCC></td></tr>
<?
for ($i=0; $row=mysql_fetch_array($result); $i++)
{
$href = "$g4[shop_path]/item.php?it_id=$row[it_id]";
$num = $rank + $i + 1;
$list = $i%2;
echo "
<tr class='list$list center'>
<td>$num</td>
<td style='padding-top:5px; padding-bottom:5px;'><a href='$href'>".get_it_image("{$row[it_id]}_s", 50, 50)."</a></td>
<td align=left><a href='$href'>".cut_str($row[it_name],30)."</a></td>
<td>$row[ct_status_1]</td>
<td>$row[ct_status_2]</td>
<td>$row[ct_status_3]</td>
<td>$row[ct_status_4]</td>
<td>$row[ct_status_5]</td>
<td>$row[ct_status_6]</td>
<td>$row[ct_status_7]</td>
<td>$row[ct_status_8]</td>
<td>$row[ct_status_sum]</td>
</tr><tr><td colspan=20 height=1 bgcolor=F5F5F5></td></tr>";
}
if ($i == 0) {
echo "<tr><td colspan=20 align=center height=100 bgcolor=#ffffff><span class=point>자료가 한건도 없습니다.</span></td></tr>\n";
}
?>
어디를 어떻게 수정해야 될까요?
아래 소스입니다.
<?
if ($sort1 == "") $sort1 = "ct_status_sum";
if ($sort2 == "") $sort2 = "desc";
$sql = " select a.it_id,
b.*,
SUM(IF(ct_status = '쇼핑',ct_qty, 0)) as ct_status_1,
SUM(IF(ct_status = '주문',ct_qty, 0)) as ct_status_2,
SUM(IF(ct_status = '준비',ct_qty, 0)) as ct_status_3,
SUM(IF(ct_status = '배송',ct_qty, 0)) as ct_status_4,
SUM(IF(ct_status = '완료',ct_qty, 0)) as ct_status_5,
SUM(IF(ct_status = '취소',ct_qty, 0)) as ct_status_6,
SUM(IF(ct_status = '반품',ct_qty, 0)) as ct_status_7,
SUM(IF(ct_status = '품절',ct_qty, 0)) as ct_status_8,
SUM(ct_qty) as ct_status_sum
from $g4[yc4_cart_table] a, $g4[yc4_item_table] b ";
$sql .= " where a.it_id = b.it_id and b.it_type1 = '1' ";
$sql .= " group by a.it_id
order by $sort1 $sort2 ";
$result = sql_query($sql);
?>
<table cellpadding=0 cellspacing=0 width=100%>
<tr><td colspan=20 height=3 bgcolor=#0E87F9></td></tr>
<tr align=center class=ht>
<td width=50>순위</td>
<td width=80></td>
<td width=''>상품명</td>
<td width=50><a href='<?=title_sort("ct_status_1",1)."&$qstr1"?>'>쇼핑</a></td>
<td width=50><a href='<?=title_sort("ct_status_2",1)."&$qstr1"?>'>주문</a></td>
<td width=50><a href='<?=title_sort("ct_status_3",1)."&$qstr1"?>'>준비</a></td>
<td width=50><a href='<?=title_sort("ct_status_4",1)."&$qstr1"?>'>배송</a></td>
<td width=50><a href='<?=title_sort("ct_status_5",1)."&$qstr1"?>'>완료</a></td>
<td width=50><a href='<?=title_sort("ct_status_6",1)."&$qstr1"?>'>취소</a></td>
<td width=50><a href='<?=title_sort("ct_status_7",1)."&$qstr1"?>'>반품</a></td>
<td width=50><a href='<?=title_sort("ct_status_8",1)."&$qstr1"?>'>품절</a></td>
<td width=50><a href='<?=title_sort("ct_status_sum",1)."&$qstr1"?>'>합계</a></td>
</tr>
<tr><td colspan=20 height=1 bgcolor=#CCCCCC></td></tr>
<?
for ($i=0; $row=mysql_fetch_array($result); $i++)
{
$href = "$g4[shop_path]/item.php?it_id=$row[it_id]";
$num = $rank + $i + 1;
$list = $i%2;
echo "
<tr class='list$list center'>
<td>$num</td>
<td style='padding-top:5px; padding-bottom:5px;'><a href='$href'>".get_it_image("{$row[it_id]}_s", 50, 50)."</a></td>
<td align=left><a href='$href'>".cut_str($row[it_name],30)."</a></td>
<td>$row[ct_status_1]</td>
<td>$row[ct_status_2]</td>
<td>$row[ct_status_3]</td>
<td>$row[ct_status_4]</td>
<td>$row[ct_status_5]</td>
<td>$row[ct_status_6]</td>
<td>$row[ct_status_7]</td>
<td>$row[ct_status_8]</td>
<td>$row[ct_status_sum]</td>
</tr><tr><td colspan=20 height=1 bgcolor=F5F5F5></td></tr>";
}
if ($i == 0) {
echo "<tr><td colspan=20 align=center height=100 bgcolor=#ffffff><span class=point>자료가 한건도 없습니다.</span></td></tr>\n";
}
?>
댓글 4개
연후하은아빠님 답변 감사합니다.
$sql .= " where a.it_id = b.it_id and b.it_type1 = '1' ";
$sql .= " group by a.it_id
를
$sql .= " where a.it_id = b.it_id and b.it_type1 = '1' ";
$sql .= " and a.ct_time between '2011-03-01 00:00:00' and '2011-03-31 23:59:59' ";
$sql .= " group by a.it_id
와 같은 방식으로 수정해 보시기 바랍니다.
$sql .= " where a.it_id = b.it_id and b.it_type1 = '1' ";
$sql .= " group by a.it_id
를
$sql .= " where a.it_id = b.it_id and b.it_type1 = '1' ";
$sql .= " and a.ct_time between '2011-03-01 00:00:00' and '2011-03-31 23:59:59' ";
$sql .= " group by a.it_id
와 같은 방식으로 수정해 보시기 바랍니다.
게시글 목록
| 번호 | 제목 |
|---|---|
| 56073 | |
| 56067 | |
| 56065 | |
| 56060 | |
| 56058 | |
| 56055 | |
| 56051 | |
| 56048 | |
| 56044 | |
| 56043 | |
| 56042 | |
| 56039 | |
| 56035 | |
| 56032 | |
| 56030 | |
| 56028 | |
| 56025 | |
| 56018 | |
| 56012 | |
| 56010 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기