while 문 항목 덧셈... 고수님들 조언좀 부탁드립니다.
본문
리스트 만들어서 작업중입니닷...
<?php
$i=1;
$d_pay = 0;
while($rs=sql_fetch_array($result)){
?>
<!-- <?php if($s_a != $rs['client_name'] || $s_b != $rs['year'] || $s_c != $rs['month']){ ?>
<tr style="background-color:#eee;">
<td colspan="9"><?php echo $d_pay; ?></td>
</tr>
<?php }?> -->
<tr>
<td><?php echo $rs['client_name'] ?></td>
<td><?php echo $rs['year'] ?></td>
<td><?php echo $rs['month'] ?></td>
<td><?php echo $rs['drafting_t'] ?></td>
<td><?php echo $rs['drafting_info'] ?></td>
<td><?php echo $rs['drafting_pay'] ?></td>
<td><?php echo $rs['payment'] ?></td>
<td><?php echo $rs['scheduled_date'] ?></td>
<td><button class="mod" idx="<?php echo $rs['id_no'] ?>">수정</button> <button class="del" idx="<?php echo $rs['id_no'] ?>">삭제</button></td>
</tr>
<form name="mod_<?=$rs['in_no']?>" id="modform_<?=$rs['id_no']?>" action="./doc_modify.php">
<input type="hidden" name="delflag" id="del_<?=$rs['id_no']?>">
<input type="hidden" name="id_no" value="<?=$rs['id_no']?>">
<tr id="mod_<?=$rs['id_no']?>" style="display:none;" class="mod_all">
<td><input type="text" name="client_name" value="<?php echo $rs['client_name'] ?>" style="width:100%"></td>
<td><input type="text" name="year" value="<?php echo $rs['year'] ?>" style="width:100%"></td>
<td><input type="text" name="month" value="<?php echo $rs['month'] ?>" style="width:100%"></td>
<td><input type="text" name="drafting_t" value="<?php echo $rs['drafting_t'] ?>" style="width:100%"></td>
<td><input type="text" name="drafting_info" value="<?php echo $rs['drafting_info'] ?>" style="width:100%"></td>
<td><input type="text" name="drafting_pay" value="<?php echo $rs['drafting_pay'] ?>" style="width:100%"></td>
<td><input type="text" name="payment" value="<?php echo $rs['payment'] ?>" style="width:100%"></td>
<td><input type="text" name="scheduled_date" value="<?php echo $rs['scheduled_date'] ?>" style="width:100%"></td>
<td><button type="submit" class="mod" idx="<?php echo $rs['id_no'] ?>">수정완료</button> <button class="cancel" onclick="location.href=''">취소</button></td>
</tr>
<?php for($i=0; $i<count($result); $i++){ ?>
<?php
if($s_a != $rs[$i]['client_name'] || $s_b != $rs[$i]['year'] || $s_c != $rs[$i]['month'] ){
$d_pay = $d_pay + $rs['drafting_pay'];
?>
<tr style="background-color:#eee;">
<td colspan="9"><?php echo $d_pay; ?></td>
</tr>
<?php }?>
<?php }?>
</form>
<?php
$s_a = $rs['client_name'];
$s_b = $rs['year'];
$s_c = $rs['month'];
?>
<?php }?>
해당 변수를 돌면서 쭉쭉쭉쭉 넣으면서
1열 1 2 3 행 값이랑
2열 1 2 3 행 값이 다를경우
tr을 뿌려주고 합계를 냅니다.
일단 값이 다를경우 합계 tr을 뿌리는 것은 성공을 했으나...
합계값을 구하는게 너무 어렵네요...
덧셈이 이렇게 어렵다니...
회색 TR에 같은 합계값을 뿌리려면 어떻게 접근해야할까요 행님들...