<?
include_once("./_common.php");
 include(G5_PATH."/gnu_lib/menu.php");

if($excel == "y") {
 $title = "Report";
 header( "Content-type: application/vnd.ms-excel" );  
 header( "Content-Disposition: attachment; filename=".date("dmYmsh").".xls");  
// $title 변수명으로 저장됩니다. 원하는 이름으로 바꾸세요
 header( "Content-Description: PHP4 Generated Data" );
}
?>

<link rel="stylesheet" href="<?php echo G5_URL ?>/css/default.css">
<script language=javascript>
  function win_print() {
              self.print();
  }
</script> 

<body > 
<table width=100%>

    <tr>
		<td  align=center><a href="print.php"> Print </a>
</td><td width=200  align=center><a href="print.php?excel=y">Export to excel</a></td><td><a href="print.php"> 총 누적 조회 </a></td>
			<td>년월별 조회</td><!--- 년별, 월별, 주간별 3단으로 출력-->
			<td><select name="">
			<option value="" selected>  
			<option value="">
		</select> </td>
			<td> <select name="">
			<option value="" selected>
			<option value="">
		</select></td>
			<td><input type=image id="btn_submit" src="../skin/board/library//img/btn_search.gif" border=0 accesskey='s'></td>
	</tr>
   

	<tr>
        <th colspan=18  align=center>
<table width=100% cellpadding="5" cellspacing="0" border="1" align="center" style="border-collapse:collapse; border:1px gray solid;">
	

	
</form>	<tr>
        <th><img src="./list_no.gif" border='0'></th>

        <th>이름 </th>
		        <th>대여권수</th>  </tr>


<tr>

	<td>
<?
if($check_year == "") {
	$i=1;
	$query5 = "select  wr_3, sum(wr_3) as sum_name from g5_write_library  group by wr_3 limit 30";
	$result5 = sql_query($query5);
	while($row  = sql_fetch_array($result5)) {
	?>

		<tr>
			<td align=center><?=$i?></td>
			<td><?=$row[wr_3]?></td>
			<td  align=center><?=$row[sum_name]?></td>
		</tr>
	<?
	$i++;
	}
}
?>
<?
if($check_year != "" && $check_month == "" ) {
	$i=1;
	$query5 = "select  wr_3, sum(wr_3) as sum_name from g5_write_library between '$check_year' and  '$check_year' group by wr_3  limit 30";
	$result5 = sql_query($query5);
	while($row  = sql_fetch_array($result5)) {
	?>

		<tr>
			<td align=center><?=$i?></td>
			<td><?=$row[wr_3]?></td>
			<td  align=center><?=$row[sum_name]?></td>
		</tr>
	<?
	$i++;
	}
}
?>
<?
if($check_year != "" && $check_month != "" ) {
	$i=1;
	$year_month = $check_year."-".$check_month;
	$query5 = "select   wr_3, sum(wr_3) as sum_name from g5_write_library  between '$check_year' and  '$check_year' group by wr_3  limit 30";
	$result5 = sql_query($query5);
	while($row  = sql_fetch_array($result5)) {
	?>

		<tr>
			<td align=center><?=$i?></td>
			<td><?=$row[wr_3]?></td>
			<td  align=center><?=$row[sum_name]?></td>
		</tr>
	<?
	$i++;
	}
}
?>
</td>
	
</tr>
</table>
</td>
	
</tr>
</table>

