날짜별,부서별 검색 합계 하는방법 부탁드려여~ 정보
날짜별,부서별 검색 합계 하는방법 부탁드려여~본문
기간별,카테고리별로 내용을 합산해서 출력하고싶은데 잘 안되네요
초보부터 시작해서 여기까지 왔는데 고수님들의 지혜를 구합니다
--소스----
<?
$sub_menu = "200700";
include_once("./_common.php");
auth_check($auth[$sub_menu], "r");
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<style>
.board_top { clear:both; }
.board_list { clear:both; width:100%; table-layout:fixed; margin:5px 0 0 0; }
.board_list th { font-weight:bold; font-size:12px; }
.board_list th { background:url(<?=$board_skin_path?>/img/title_bg.gif) repeat-x; }
.board_list th { white-space:nowrap; height:34px; overflow:hidden; text-align:center; }
.board_list th { border-top:1px solid #ddd; border-bottom:1px solid #ddd; }
.board_list tr.bg0 { background-color:#fafafa; }
.board_list tr.bg1 { background-color:#ffffff; }
.board_list td { padding:.5em;}
.board_list td { border-bottom:1px solid #ddd; }
.board_list td.num { color:#999999; text-align:center; }
.board_list td.checkbox { text-align:center; }
.board_list td.subject { overflow:hidden; color:black;}
.board_list td.name { text-align:center;}
.board_list td.datetime { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list td.hit { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list td.count { font:normal 12px tahoma; color:gray; text-align:center; }
.board_list td.good { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list td.nogood { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list .notice { font-weight:normal; }
.board_list .current { font:bold 11px tahoma; color:#E15916; }
.board_list .comment { font-family:Tahoma; font-size:10px; color:#EE5A00; }
.board_list td a.nwin { color:gray; font-size:11px; font-family:dotum; text-decoration:none;}
.board_list td a.nwin:hover { color:red;}
.board_button { clear:both; margin:10px 0 0 0; }
.board_page { font-family:tahoma; font-size:11px; clear:both; text-align:center; vertical-align:middle; line-height:1.5em;}
.board_page a, .board_page a:hover span, .board_page a span, .board_page b {
text-decoration:none; width:24px; font-weight:bold; display:inline-block; color:#222222; }
.board_page a:hover { text-decoration:none; }
.board_page a span { border:1px solid #CCCCCC; }
.board_page a:hover span { border:1px solid red; cursor:pointer; color:red; }
.board_page b { border:1px solid red; color:red; }
.board_search { text-align:center; margin:10px 0 0 0; }
.board_search .stx { width:200px; height:21px; border:1px solid #9A9A9A; border-right:1px solid #D8D8D8; border-bottom:1px solid #D8D8D8; }
#today input { font-size:11px; font-family:dotum; }
</style>
<script type="text/javascript">
document.ftoday.sst.value = "<?=$sst;?>";
function ftoday_submit(field, f) {
if (!f) {
if (document.ftoday)
f = document.ftoday;
else
f = document.forms[0];
}
f.sst.value = field;
f.submit();
}
</script>
<?
echo $fr_date;
echo $to_date;
?>
<!-- 게시판 목록 시작 -->
<table width="<?=$width?>" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<!-- 제목 -->
<form name="fboardlist" method="post">
<input type="hidden" name="sca" value="<?=$sca?>">
<input type="hidden" name="sop" value="<?=$sop?>">
<input type="hidden" name="stx" value="<?=$stx?>">
<input type="hidden" name="sfl" value="<?=$sfl?>">
<input type='hidden' name='bo_table' value='<?=$_REQUEST[bo_table]?>'>
<input type='hidden' name='gr_id' value='<?=$_REQUEST[gr_id]?>'>
<input type='hidden' name='skin' value='<?=$_REQUEST[skin]?>'>
<input type='hidden' name='spt' value='<?=$spt?>'>
<input type='hidden' name='page' value='<?=$page?>'>
<input type='hidden' name='sw' value=''>
<table cellspacing="0" cellpadding="0" class="board_list">
<tr>
<th>부서</th>
<? if ($is_checkbox) { ?><th><input onclick="if (this.checked) all_checked(true); else all_checked(false);" type="checkbox"></th><?}?>
<th>재적</th>
<th>출석</th>
<th>결석</th>
<th >평균</th>
<th>신입</th>
<th>백분율</th>
<th><?=subject_sort_link('wr_datetime', $qstr2, 1)?>날짜</a></th>
</tr>
<?
// 선택옵션으로 인해 셀합치기가 가변적으로 변함
$colspan = 8;
$board_skin_path="/gnuboard4/skin/board/today";
$wr_1 = urldecode($writer);
$rank = 0 ;
$bo_table = "today";
// 게시판 테이블 출력
$bo_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
/************************************************** 처음 */
$sql = " select * from $bo_write_table ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
// 순번
if ($row[ca_name]== $ca_name ) {
$rank = $rank + 1;
$w6 = $row[wr_6]; //재적
$row_wr_6=$row_wr_6 + $w6;
$w13 = $row[wr_13]; //총출석
$row_wr_13=$row_wr_13 + $w13;
$gul=$row_wr_6 - $row_wr_13 ; //결석
$evg1=$row_wr_13 / $rank; //평균
$evg = number_format($evg1, 2);
$w8 = $row[wr_8]; //신입
$row_wr_8=$row_wr_8 + $w8;
$per=($row_wr_13 / $row_wr_6) * 100 ; //백분율
$per1 = number_format($per, 2);
$wr_datetime = $row[wr_datetime];
$ca_name=$row[ca_name];
} // ca_name같으면 여기까지
$rank = "1";
$w6 = $row[wr_6]; //재적
$row_wr_6= $w6;
$w13 = $row[wr_13]; //총출석
$row_wr_13= $w13;
$gul=$row_wr_6 - $row_wr_13 ; //결석
$evg1=$row_wr_13 / $rank; //평균
$evg = number_format($evg1, 2);
$w8 = $row[wr_8]; //신입
$row_wr_8= $w8;
$per=($row_wr_13 / $row_wr_6) * 100 ; //백분율
$per1 = number_format($per, 2);
$wr_datetime = $row[wr_datetime];
$ca_name=$row[ca_name];
?>
<tr class="bg<?=$bg?>">
<td class="count">
<?=$ca_name?></td>
<td class="count"><?=$row_wr_6?></td>
<td class="count"><?=$row_wr_13?></td>
<td class="count"><?=$gul?></td>
<td class="count"><?=$evg?></td>
<td class="count"><?=$row_wr_8?></td>
<td class="count"><?=$per1?></td>
<td class="count"><?= $wr_datetime?></td>
</tr>
<?}?>
<? if (count($list) == 0) { echo "<tr><td colspan='$colspan' height=100 align=center>게시물이 없습니다.</td></tr>"; } ?>
</table>
</form>
<!--------------------------------------------------------- 게시판 목록 끝 -->
초보부터 시작해서 여기까지 왔는데 고수님들의 지혜를 구합니다
--소스----
<?
$sub_menu = "200700";
include_once("./_common.php");
auth_check($auth[$sub_menu], "r");
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<style>
.board_top { clear:both; }
.board_list { clear:both; width:100%; table-layout:fixed; margin:5px 0 0 0; }
.board_list th { font-weight:bold; font-size:12px; }
.board_list th { background:url(<?=$board_skin_path?>/img/title_bg.gif) repeat-x; }
.board_list th { white-space:nowrap; height:34px; overflow:hidden; text-align:center; }
.board_list th { border-top:1px solid #ddd; border-bottom:1px solid #ddd; }
.board_list tr.bg0 { background-color:#fafafa; }
.board_list tr.bg1 { background-color:#ffffff; }
.board_list td { padding:.5em;}
.board_list td { border-bottom:1px solid #ddd; }
.board_list td.num { color:#999999; text-align:center; }
.board_list td.checkbox { text-align:center; }
.board_list td.subject { overflow:hidden; color:black;}
.board_list td.name { text-align:center;}
.board_list td.datetime { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list td.hit { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list td.count { font:normal 12px tahoma; color:gray; text-align:center; }
.board_list td.good { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list td.nogood { font:normal 11px tahoma; color:gray; text-align:center; }
.board_list .notice { font-weight:normal; }
.board_list .current { font:bold 11px tahoma; color:#E15916; }
.board_list .comment { font-family:Tahoma; font-size:10px; color:#EE5A00; }
.board_list td a.nwin { color:gray; font-size:11px; font-family:dotum; text-decoration:none;}
.board_list td a.nwin:hover { color:red;}
.board_button { clear:both; margin:10px 0 0 0; }
.board_page { font-family:tahoma; font-size:11px; clear:both; text-align:center; vertical-align:middle; line-height:1.5em;}
.board_page a, .board_page a:hover span, .board_page a span, .board_page b {
text-decoration:none; width:24px; font-weight:bold; display:inline-block; color:#222222; }
.board_page a:hover { text-decoration:none; }
.board_page a span { border:1px solid #CCCCCC; }
.board_page a:hover span { border:1px solid red; cursor:pointer; color:red; }
.board_page b { border:1px solid red; color:red; }
.board_search { text-align:center; margin:10px 0 0 0; }
.board_search .stx { width:200px; height:21px; border:1px solid #9A9A9A; border-right:1px solid #D8D8D8; border-bottom:1px solid #D8D8D8; }
#today input { font-size:11px; font-family:dotum; }
</style>
<script type="text/javascript">
document.ftoday.sst.value = "<?=$sst;?>";
function ftoday_submit(field, f) {
if (!f) {
if (document.ftoday)
f = document.ftoday;
else
f = document.forms[0];
}
f.sst.value = field;
f.submit();
}
</script>
<?
echo $fr_date;
echo $to_date;
?>
<!-- 게시판 목록 시작 -->
<table width="<?=$width?>" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<!-- 제목 -->
<form name="fboardlist" method="post">
<input type="hidden" name="sca" value="<?=$sca?>">
<input type="hidden" name="sop" value="<?=$sop?>">
<input type="hidden" name="stx" value="<?=$stx?>">
<input type="hidden" name="sfl" value="<?=$sfl?>">
<input type='hidden' name='bo_table' value='<?=$_REQUEST[bo_table]?>'>
<input type='hidden' name='gr_id' value='<?=$_REQUEST[gr_id]?>'>
<input type='hidden' name='skin' value='<?=$_REQUEST[skin]?>'>
<input type='hidden' name='spt' value='<?=$spt?>'>
<input type='hidden' name='page' value='<?=$page?>'>
<input type='hidden' name='sw' value=''>
<table cellspacing="0" cellpadding="0" class="board_list">
<tr>
<th>부서</th>
<? if ($is_checkbox) { ?><th><input onclick="if (this.checked) all_checked(true); else all_checked(false);" type="checkbox"></th><?}?>
<th>재적</th>
<th>출석</th>
<th>결석</th>
<th >평균</th>
<th>신입</th>
<th>백분율</th>
<th><?=subject_sort_link('wr_datetime', $qstr2, 1)?>날짜</a></th>
</tr>
<?
// 선택옵션으로 인해 셀합치기가 가변적으로 변함
$colspan = 8;
$board_skin_path="/gnuboard4/skin/board/today";
$wr_1 = urldecode($writer);
$rank = 0 ;
$bo_table = "today";
// 게시판 테이블 출력
$bo_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
/************************************************** 처음 */
$sql = " select * from $bo_write_table ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
// 순번
if ($row[ca_name]== $ca_name ) {
$rank = $rank + 1;
$w6 = $row[wr_6]; //재적
$row_wr_6=$row_wr_6 + $w6;
$w13 = $row[wr_13]; //총출석
$row_wr_13=$row_wr_13 + $w13;
$gul=$row_wr_6 - $row_wr_13 ; //결석
$evg1=$row_wr_13 / $rank; //평균
$evg = number_format($evg1, 2);
$w8 = $row[wr_8]; //신입
$row_wr_8=$row_wr_8 + $w8;
$per=($row_wr_13 / $row_wr_6) * 100 ; //백분율
$per1 = number_format($per, 2);
$wr_datetime = $row[wr_datetime];
$ca_name=$row[ca_name];
} // ca_name같으면 여기까지
$rank = "1";
$w6 = $row[wr_6]; //재적
$row_wr_6= $w6;
$w13 = $row[wr_13]; //총출석
$row_wr_13= $w13;
$gul=$row_wr_6 - $row_wr_13 ; //결석
$evg1=$row_wr_13 / $rank; //평균
$evg = number_format($evg1, 2);
$w8 = $row[wr_8]; //신입
$row_wr_8= $w8;
$per=($row_wr_13 / $row_wr_6) * 100 ; //백분율
$per1 = number_format($per, 2);
$wr_datetime = $row[wr_datetime];
$ca_name=$row[ca_name];
?>
<tr class="bg<?=$bg?>">
<td class="count">
<?=$ca_name?></td>
<td class="count"><?=$row_wr_6?></td>
<td class="count"><?=$row_wr_13?></td>
<td class="count"><?=$gul?></td>
<td class="count"><?=$evg?></td>
<td class="count"><?=$row_wr_8?></td>
<td class="count"><?=$per1?></td>
<td class="count"><?= $wr_datetime?></td>
</tr>
<?}?>
<? if (count($list) == 0) { echo "<tr><td colspan='$colspan' height=100 align=center>게시물이 없습니다.</td></tr>"; } ?>
</table>
</form>
<!--------------------------------------------------------- 게시판 목록 끝 -->
댓글 전체
group by 를 쓰시면 됩니다
답 넘~감사합니다^^
사용법은 검색해서 해보겠습니다
감사^^감사^^ 꾸벅^^
사용법은 검색해서 해보겠습니다
감사^^감사^^ 꾸벅^^
$sql = " select * from $bo_write_table group by ca_name ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
// 순번
//if ($row[ca_name]== $ca_name ) {
$rank = $rank + 1;
$w6 = $row[wr_6]; //재적
$row_wr_6=$row_wr_6 + $w6;
$w13 = $row[wr_13]; //총출석
$row_wr_13=$row_wr_13 + $w13;
$gul=$row_wr_6 - $row_wr_13 ; //결석
$evg1=$row_wr_13 / $rank; //평균
$evg = number_format($evg1, 2);
$w8 = $row[wr_8]; //신입
$row_wr_8=$row_wr_8 + $w8;
$per=($row_wr_13 / $row_wr_6) * 100 ; //백분율
$per1 = number_format($per, 2);
$wr_datetime = $row[wr_datetime];
$ca_name=$row[ca_name];
// ca_name같으면 여기까지
?>
<tr class="bg<?=$bg?>">
<td class="count">
<?=$ca_name?></td>
<td class="count"><?=$row_wr_6?></td>
<td class="count"><?=$row_wr_13?></td>
<td class="count"><?=$gul?></td>
<td class="count"><?=$evg?></td>
<td class="count"><?=$row_wr_8?></td>
<td class="count"><?=$per1?></td>
<td class="count"><?= $wr_datetime?></td>
</tr>
<?}?>
group by로 하니까 $row_wr_6; 이 값이 계속 누적되어서 계산되네요
같은 ca_name 의 값을 누적하여 보여지고나서
다른 ca_name 값이 0 부터 시작해야하는데
계속 누적되는데 어떻게 해야죠?
왕 초보 수준이네요 ㅎㅎ
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
// 순번
//if ($row[ca_name]== $ca_name ) {
$rank = $rank + 1;
$w6 = $row[wr_6]; //재적
$row_wr_6=$row_wr_6 + $w6;
$w13 = $row[wr_13]; //총출석
$row_wr_13=$row_wr_13 + $w13;
$gul=$row_wr_6 - $row_wr_13 ; //결석
$evg1=$row_wr_13 / $rank; //평균
$evg = number_format($evg1, 2);
$w8 = $row[wr_8]; //신입
$row_wr_8=$row_wr_8 + $w8;
$per=($row_wr_13 / $row_wr_6) * 100 ; //백분율
$per1 = number_format($per, 2);
$wr_datetime = $row[wr_datetime];
$ca_name=$row[ca_name];
// ca_name같으면 여기까지
?>
<tr class="bg<?=$bg?>">
<td class="count">
<?=$ca_name?></td>
<td class="count"><?=$row_wr_6?></td>
<td class="count"><?=$row_wr_13?></td>
<td class="count"><?=$gul?></td>
<td class="count"><?=$evg?></td>
<td class="count"><?=$row_wr_8?></td>
<td class="count"><?=$per1?></td>
<td class="count"><?= $wr_datetime?></td>
</tr>
<?}?>
group by로 하니까 $row_wr_6; 이 값이 계속 누적되어서 계산되네요
같은 ca_name 의 값을 누적하여 보여지고나서
다른 ca_name 값이 0 부터 시작해야하는데
계속 누적되는데 어떻게 해야죠?
왕 초보 수준이네요 ㅎㅎ