숫합 합계 방법 문의드립니다.
본문
안녕하세요 문의좀드리겠습니다.
<?php echo number_format($ct_price['stotal']); ?>
이부분의 숫자를
페이지 아무곳에나 숫자 합계를 하는 방법을 알 수 있을까요`?
<?php
$chk_cnt = 0;
for($i=0; $row=sql_fetch_array($result); $i++) {
// 상품이미지
$image = get_it_image($row['it_id'], 50, 50);
// 상품의 옵션정보
$sql = " select ct_id, it_id, ct_price, ct_point, ct_qty, ct_option, ct_status, cp_price, ct_stock_use, ct_point_use, ct_send_cost, io_type, io_price
from {$g5['g5_shop_cart_table']}
where od_id = '{$od['od_id']}'
and it_id = '{$row['it_id']}'
order by io_type asc, ct_id asc ";
$res = sql_query($sql);
$rowspan = sql_num_rows($res);
// 합계금액 계산
$sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
SUM(ct_qty) as qty
from {$g5['g5_shop_cart_table']}
where it_id = '{$row['it_id']}'
and od_id = '{$od['od_id']}' ";
$sum = sql_fetch($sql);
// 배송비
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'], $od['od_id']);
if($sendcost == 0)
$ct_send_cost = '무료';
}
for($k=0; $opt=sql_fetch_array($res); $k++) {
if($opt['io_type'])
$opt_price = $opt['io_price'];
else
$opt_price = $opt['ct_price'] + $opt['io_price'];
// 소계
$ct_price['stotal'] = $opt_price * $opt['ct_qty'];
$ct_point['stotal'] = $opt['ct_point'] * $opt['ct_qty'];
?>
<tr style=" height: 100px;">
<?php if($k == 0) { ?>
<td rowspan="<?php echo $rowspan; ?>" class="td_chk" >
<?php echo $i+1; ?> </td>
<td rowspan="<?php echo $rowspan; ?>" class="td_left">
<a href="./itemform.php?w=u&it_id=<?php echo $row['it_id']; ?>"><?php echo $image; ?> <?php echo stripslashes($row['it_name']); ?></a>
<?php if($od['od_tax_flag'] && $row['ct_notax']) echo '[비과세상품]'; ?>
</td>
<?php } ?>
<td><?php $it= sql_fetch("select it_maker , it_basic from {$g5['g5_shop_item_table']} where it_id = '{$row['it_id']}' "); ?><?php echo $it['it_maker']; ?> </td>
<td class="td_left">
<?php $it= sql_fetch("select it_origin , it_basic from {$g5['g5_shop_item_table']} where it_id = '{$row['it_id']}' "); ?> <?php echo $it['it_origin']; ?>
</td>
<td class="td_num">
<label for="ct_qty_<?php echo $chk_cnt; ?>" class="sound_only" value="<?php echo $opt['ct_qty']; ?>"> 수량</label>
<span class="quantity"><?php echo $opt['ct_qty']; ?></span>
</td>
<td class="td_num_right "><input type="text" name="opt_price" class="price" value="<?php echo number_format($opt_price); ?>" onKeyup="inputNumberAutoComma(this);"> </td>
<td class="td_num_right"><span class="calc_price"><?php echo number_format($ct_price['stotal']); ?></span></td>
</tr>
<?php
$chk_cnt++;
}
?>
<?php
}
?>
답변 1
<?php echo number_format($ct_price['stotal']); ?>
이건 출력할때 사용하시는 방버이구요
<?php
$tot_ct_price = 0;
//처음에 이걸 넣으시고
$tot_ct_price += $ct_price['stotal'];
//와 같이 필요한 자리에서 합계를 만드실 내용을 더하시고
//출력은
echo number_format($tot_ct_price);
//로 출력하시면됩니다.
?>
답변을 작성하시기 전에 로그인 해주세요.