header('Content-Type: text/html; charset=tis-620');
include('../db_config.php');
$sql="select *	from sk1_cct a,sch b where a.smis=b.smis and b.scgrp='$sg' ";
$result=mysql_query($sql);
echo "
	
	| ที่ | 
	โรงเรียน | 
	ดูรหัส | 
	
";
$rw=1; $tn=0;
while ($db=mysql_fetch_array($result)) {
	$sql1="select * from sk1_cct where ksmis='$db[smis]' and chk='1' ";
	$result1=mysql_query($sql1);
	$n=mysql_num_rows($result1);
	if ($n>0) { $ast=$n; } else { $ast='-'; }
	echo "
		| $rw | 
		$db[sname] | 
		$ast | 
		
";
	$rw++; $tn+=$n;
}
$tstd=number_format($tn,0,'.',',');
echo "
	| รวม | 
	$tn | 
	
	

";
?>