리스트에서 합산을 뽑아 볼려하는데요,,,

· 2013-07-18 (목) 09:36:05 · 1658 · 4
3.jpg
그림과 같은 경우 금액을 합산하여 아래에 표기 할려하는데요,,
그누를 뒤지고 뒤져서 해보앗는데,,
저는 개속 0으로만 표기가 되네요,,,

제가 아마 수식을 잘못 써서 그런것 같은데 뭐가 잘못 된걸까요?


<?
$sub_menu = "770150";
include_once( "./_common.php" );
auth_check( $auth[$sub_menu], "r" );
$g4[title] = "거래명세서";
include_once( "$g4[admin_path]/admin.head.php" );
$sql_common = " from $g4[synd_tax] ";

$sql_search = " where (1) ";

if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "co_content" :
$sql_search .= " ($sfl like '$stx%') ";
break;
case "co_subject" :
$sql_search .= " ($sfl like '$stx%') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}

$sql = " select count(*) as cnt
$sql_common
$sql_search ";

$row = sql_fetch( $sql );
$total_count = $row[cnt];
$rows = $config[cf_page_rows];
$total_page = ceil( $total_count / $rows );
if ( $page == "" )
{
$page = 1;
}
$from_record = ( $page - 1 ) * $rows;

$sql = "select *
$sql_common
$sql_search
order by co_num limit $from_record, $config[cf_page_rows] ";

$result = sql_query( $sql );

echo subtitle($g4[title]);
?>

<table cellpadding=0 cellspacing=0 width=100%>
<form name=fsearch method=get>
<tr>
<td width=100><a href='<?=$_SERVER[PHP_SELF]?>'>처음</a> (건수 : <?=number_format($total_count)?>)</td>
<td align=center> </td>
<td width=90>
<select name=sfl>
<option value='co_content'>상호명</option>
<option value='co_subject'>사업자번호</option>
</select><?if ($stx){?><script language='javascript'>document.fsearch.sfl.value = '<?=$sfl?>';</script><?}?>
</td>
<td width=125><input type=text name=stx class=ed required itemname='검색어' value='<?=$stx?>'></td>
<td width=20 align=right><input type=image src='<?=$g4[admin_path]?>/img/btn_search.gif' align=absmiddle></td>
</tr>
</form>
</table>
<form name=fboardlist method=post>
<input type=hidden name=sst value="<?=$sst?>">
<input type=hidden name=sod value="<?=$sod?>">
<input type=hidden name=sfl value="<?=$sfl?>">
<input type=hidden name=stx value="<?=$stx?>">
<input type=hidden name=page value="<?=$page?>">

<table cellpadding=0 cellspacing=0 width=100%>
<colgroup width=40>
<colgroup width=''>
<colgroup width=200>
<colgroup width=80>
<colgroup width=80>
<colgroup width=80>
<tr>
<td colspan=6 height=2 bgcolor=#0E87F9></td>
</tr>
<tr align=center class=ht>
<td>번호</td>
<td>상호명</td>
<td>사업자번호</td>
<td>금액</td>
<td>등록일</td>
<td><a href='./tax_g_form.php'><img src='<?=$g4[admin_path]?>/img/icon_insert.gif' border=0></a></td>
</tr>
<tr>
<td colspan=6 height=1 bgcolor=#CCCCCC></td>
</tr>
<?
$i = 0;
for ( ; $row = mysql_fetch_array( $result ); ++$i )
{
$s_mod = icon( "수정", "./tax_g_form.php?w=u&co_num=$row[co_num]$qstr" );
$s_del = icon( "삭제", "javascript:del('./tax_g_update.php?w=d&co_no=$row[co_no]')" );

$list = $i % 2;
?>

<tr class='list<?=$list?> ht'>
<td align=center><?=$row[co_num]*-1?></td>
<td><?=$row[co_content]?></td>
<td align=center><?=$row[co_subject]?></td>
<td align=center><?=number_format($row[co_b15])?></td>
<td align=center><?=substr($row[co_datetime],2,8)?></td>
<td align=center width=80><?=$s_mod?> <?=$s_del?> <a href="#" onClick="window.open('tax_print.php?co_no=<?=$row[co_no]?>', '', 'left=150, top=10, width=700, height=700, scrollbars=1');" onfocus="blur();"><img src="<?=$g4[admin_path]?>/img/icon_view.gif" border=0 title='출력'></a> </td>
</tr>
<?
}
if ( $i == 0 )
{
echo "<tr><td colspan=6 align=center height=100 bgcolor=#ffffff><span class=point>자료가 한건도 없습니다.</span></td></tr>\n";
}
?>
<tr>
<td colspan=6 height=1 bgcolor=#CCCCCC></td>
</tr>
</table>
<table width=100%>
<tr bgcolor=#ffffff>
<td width=50%></td>
<td width=50% align=right><?=get_paging( $config[cf_write_pages], $page, $total_page, "{$_SERVER['PHP_SELF']}?{$qstr}&page=" )?></td>
</tr>
</table>
<table width="200" border="1">
<tr>
<td> </td>
<td><?
for($i = 0; $i < count($list); $i++) $sum += $row[co_b15];
echo number_format($sum);
?></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<?
include_once( "{$g4['admin_path']}/admin.tail.php" );
?>


해당 내용입니다.. 도와주세요~~

첨부파일

3.jpg (43.4 KB)
0회 2013-07-18 09:36
|

댓글 4개

2013-07-18 (목) 10:00:55
<?
$i = 0;
for ( ; $row = mysql_fetch_array( $result ); ++$i )
{
$sum += $row[co_b15]; // for $row 안에서 변수에 담고 하단 출력
2013-07-18 (목) 10:39:51
흐미 제가 멀잘못 햇는지 백지화면만,, 흑흑
2013-07-18 (목) 13:34:24
이렇게 함 넣어보세욤~
<?
$rowsum = sql_fetch(" select sum($row[co_b15]) as sum_in from $g4[synd_tax] $sql_search");
$rowsum_in = $rowsum[sum_in];
$total_money = Number_Format("$rowsum_in");
echo "$total_money";
?>원
2013-07-18 (목) 14:24:25
select sum() as sum_in from synd_tax where (1)

1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') as sum_in from synd_tax where (1)' at line 1

error file : /adm/skin/tax_g_list.php

이런식의 오류가 나는데 테이블 생성이 안되서 그런건가요?

<?=number_format($row[co_b15])?> 이부분은 정상적으로 나오거든요 ㅜ..ㅜ
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
13-07-18 조회 949
13-07-18 조회 1,065
13-07-18 조회 2,611
13-07-18 조회 1,882
13-07-18 조회 2,121
13-07-18 조회 2,477
13-07-18 조회 2,237
13-07-18 조회 1,659
13-07-18 조회 1,223
13-07-18 조회 2,571
13-07-18 조회 1,798
13-07-18 조회 861
13-07-18 조회 1,076
13-07-18 조회 858
13-07-18 조회 1,085
13-07-17 조회 2,203
13-07-17 조회 1,287
13-07-17 조회 1,268
13-07-17 조회 964
13-07-17 조회 1,039