<tr><td height=50><a href="<?=$g4[path]?>/bbs/board.php?bo_table=static&wr_id=4&page=0"><b><u>Puchase summary</u></b></a></td></tr>
<tr>
<?
	if($want_year =="")  $here = date("Y"); else $here = $want_year;
//평균 단가
$i=0;


	$query4 = "select avg(wr_3) as priceavg, max(wr_3)  as pricemax, min(wr_3)  as pricemin, wr_subject from g4_write_buy  where left(wr_datetime, 4) = '$here'   group by wr_subject " ;
		$result4 = sql_query($query4);
		while($row  = sql_fetch_array($result4)) {
			$avg[$i] = $row[priceavg]; //구입처
			$max[$i] = $row[pricemax]; //제조사
			$min[$i] = $row[pricemin]; //물품명
			$goods[$i] = $row[wr_subject];
	//	echo $avg[$i];
			$i++;
		}
?>
	






<table class="t_ex2">
	<tr><th bgcolor=#E2F2D3 width=50>&nbsp;상품&nbsp;</th>
		<?

	for($i=0; $i < count($goods); $i++) {

		echo "<th class='c1' width=7% align=center> ".$goods[$i]." </th>";
	}
?></tr>


<tr><td  bgcolor=#CCFFFF align=center>&nbsp;평균단가&nbsp;</td>
<?

	for($i=0; $i < count($goods); $i++) {
	
			echo "<td   class='c2' width=7% align=right> ".number_format($avg[$i])."&nbsp;</td>";

			}
?>

</tr><tr><td  bgcolor=#FFFF00 align=center>&nbsp;최고단가&nbsp;</td>
<?

	for($i=0; $i < count($goods); $i++) {
	
		
echo "<th class='c4' width=7% align=right> <font size=2 color=black>".number_format($max[$i])."</font> </th>";
	}
?>
</tr>
<tr ><td bgcolor=#CB9696  align=center>&nbsp;최저단가&nbsp;</td>
<?
for($i=0; $i < count($goods); $i++) {

	echo "<td  class='c3' width=7% align=right> ".number_format($min[$i])."&nbsp;</td>";
			}
?>
</tr>
</table>



    </td>
</tr>