더하기 빼기가 이렇게 어려울 줄이야,,,,
기존스킨을 활용해서 약간 변경하려는데 ...
wr_8의 월별 합산 및 총계는 잘나옵니다.
그런데 wr_255도 월별 합산을 추가하려는데 잘 안되네요,,,
for문 안에 뭔가를 집어넣어줘야 할거 같은데...
도와주세요,,,
$g5['title'] = '월별 실적';
include_once('./member_count.sub.php');
$colspan = 4;
$max = 0;
$sum_count = 0;
$sql = " select SUBSTRING(wr_datetime,1,7) as vs_month, sum(wr_8) as total, sum(wr_255) as refund
from g5_write_test
where date(wr_datetime) between '{$fr_date}' and '{$to_date}'
group by vs_month
order by vs_month desc";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$arr[$row['vs_month']] = $row['total'];
if ($row['total'] > $max) $max = $row['total'];
$sum_count += $row['total'];
}
?>
<div class="tbl_head01 tbl_wrap">
<table>
<caption><?php echo $g5['title']; ?> 목록</caption>
<thead>
<tr>
<th scope="col">년-월</th>
<th scope="col">그래프</th>
<th scope="col">총입금</th>
<th scope="col">총환불</th>
<th scope="col">총실적</th>
<th scope="col">비율(%)</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2">합계</td>
<td><strong><?php echo number_format($sum_count) ?></strong></td>
<td><?php echo number_format($sum_refund) ?></td>
<td></td>
</td></td>
<td>100%</td>
</tr>
</tfoot>
<tbody>
<?php
$i = 0;
$k = 0;
$save_count = -1;
$tot_count = 0;
if (count($arr)) {
foreach ($arr as $key=>$value) {
$count = $value;
$rate = ($count / $sum_count * 100);
$s_rate = number_format($rate, 1);
$bg = 'bg'.($i%2);
?>
<tr class="<?php echo $bg; ?>">
<td class="td_category"><a href="./visit_date.php?fr_date=<?php echo $key ?>-01&to_date=<?php echo $key ?>-31"><?php echo $key ?></a></td>
<td>
<div class="visit_bar">
<span style="width:<?php echo $s_rate ?>%"></span>
</div>
</td>
<td class="td_numbig"><?php echo number_format($value) ?></td>
<td class="td_numbig"></td>
<td class="td_numbig"></td>
답변 5개 / 댓글 5개
refund가 월별로 표시는 안됩니다. 라는 말씀이
각각 월별로 안나타나는 증상을 말씀하시는건가요??
혹시 각각 월별의 표시를 $sum_refund 로찍으신건 아닐까요??
각각의 월별의 표시는 $row[refund] 로 찍으시면 될것 같은데요..
아니라면 $arr[$row['vs_month']] = $row['total']; 값처럼
$arr[$row['vs_month2']] = $row['refund']; 라는 값을 넣어주셔서 사용하셔도 될것같네요
sum(wr_8) as total 에 대해서는 하단 for 문에 $sum_count += $row['total'];해서 합산을 하라고 명령이 되어있는데...sum(wr_255) as refound 에 대해서는 합산을 하라는 명령이 없습니다.
해서 해당 부분을 추가 하시면 될것 같고 위에 댓글을 달아주신
뽁스 님의 의견대로 $sum_refund += $row['refund'];것을추가 하시면 될거라 생각됩니다.
$sum_count += $row['total']; 밑에
$sum_refund += $row['refund']; 을 추가 하시면 될것으로 보여집니다.
머시기거시기님이 작성하신 원본에서 <?php echo number_format($sum_refund) ?>이런 내용이 존재 하나 저 $sum_refund에 대해 어느곳에도 선언된 곳이 없어서 그런게 아닐까 조심스레 생각해봅니다.
제가 머시기 거시기 님의 문의 내용을 제대로 이해했는지 모르겠네요..아니라면 죄송합니다.
if ($row['total'] > $max) $max = $row['total'];
$sum_count += $row['total'];
이부분 아래에
$sum_refund += $row['refund'];
이렇게 추가하면 될 것 같은데요?
답변에 대한 댓글 2개
이 부분에서 월별 총입금을 배열로 집어넣고
if (count($arr)) {
foreach ($arr as $key=>$value) {
여기서 해당 배열의 값이 있으면 foreach 로 배열값 길이만큼 반복문을 돌립니다.
<td class="td_numbig"><?php echo number_format($value) ?></td>
이 부분의 $value 가 배열($arr)에 들어가 있는 값들을 표시해주는거죠.
$arr 배열에 refund 값을 추가 후 작업해보세요.
답변을 작성하려면 로그인이 필요합니다.