header('Content-Type: text/html; charset=tis-620');
include('../db_config.php');
$sql="select *	from sk1_std59 a,sk1_sch b where a.smis=b.smis and 
	scgrp != 'prv' order by sampur";
$result=mysql_query($sql);
echo "
จำนวนนักเรียน ทุกชั้นเรียน สังกัด สพป.ศรีสะเกษ เขต 1 ข้อมูล ณ วันที่ 16 พ.ค.2559 
	
	
	| ที่ | 
	โรงเรียน | 
	อำเภอ | 
	อนุบาล 1 | 
	อนุบาล 2 | 
	ป.1 | 
	ป.2 | 
	ป.3 | 
	ป.4 | 
	ป.5 | 
	ป.6 | 
	ม.1 | 
	ม.2 | 
	ม.3 | 
	ม.4 | 
	ม.5 | 
	ม.6 | 
	รวม | 	
	
	| ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	ชาย | 
	หญิง | 
	รวม | 
	
";
$rw=1;
while ($db=mysql_fetch_array($result)) {
	$allm=$db[a1m]+$db[a2m]+$db[p1m]+$db[p2m]+$db[p3m]+$db[p4m]+$db[p5m]+$db[p6m]+
		$db[m1m]+$db[m2m]+$db[m3m]+$db[m4m]+$db[m5m]+$db[m6m];
	$allf=$db[a1f]+$db[a2f]+$db[p1f]+$db[p2f]+$db[p3f]+$db[p4f]+$db[p5f]+$db[p6f]+
		$db[m1f]+$db[m2f]+$db[m3f]+$db[m4f]+$db[m5f]+$db[m6f];
	$all=$allm+$allf;
	if (empty($all)) { $col='#ffe6cc'; } else { $col='#dafed3'; }
	echo "
		| $rw | 
		$db[sname] | 
		$db[sampur] | 
		$db[a1m] | 
		$db[a1f] | 
		$db[a2m] | 
		$db[a2f] | 
		$db[p1m] | 
		$db[p1f] | 
		$db[p2m] | 
		$db[p2f] | 
		$db[p3m] | 
		$db[p3f] | 
		$db[p4m] | 
		$db[p4f] | 
		$db[p5m] | 
		$db[p5f] | 
		$db[p6m] | 
		$db[p6f] | 
		$db[m1m] | 
		$db[m1f] | 
		$db[m2m] | 
		$db[m2f] | 
		$db[m3m] | 
		$db[m3f] | 
		$db[m4m] | 
		$db[m4f] | 
		$db[m5m] | 
		$db[m5f] | 
		$db[m6m] | 
		$db[m6f] | 
		$allm | 
		$allf | 
		$all | 
		
";
	$rw++;
	$sa1m+=$db[a1m];
	$sa1f+=$db[a1f];
	$sa2m+=$db[a2m];
	$sa2f+=$db[a2f];
	$sp1m+=$db[p1m];
	$sp1f+=$db[p1f];
	$sp2m+=$db[p2m];
	$sp2f+=$db[p2f];
	$sp3m+=$db[p3m];
	$sp3f+=$db[p3f];
	$sp4m+=$db[p4m];
	$sp4f+=$db[p4f];
	$sp5m+=$db[p5m];
	$sp5f+=$db[p5f];
	$sp6m+=$db[p6m];
	$sp6f+=$db[p6f];
	$sm1m+=$db[m1m];
	$sm1f+=$db[m1f];
	$sm2m+=$db[m2m];
	$sm2f+=$db[m2f];
	$sm3m+=$db[m3m];
	$sm3f+=$db[m3f];
	$sm4m+=$db[m4m];
	$sm4f+=$db[m4f];
	$sm5m+=$db[m5m];
	$sm5f+=$db[m5f];
	$sm6m+=$db[m6m];
	$sm6f+=$db[m6f];
	$tallm+=$allm;
	$tallf+=$allf;
	$tall+=$all;
}
echo "
	| รวม | 
	$sa1m | 
	$sa1f | 
	$sa2m | 
	$sa1f | 
	$sp1m | 
	$sp1f | 
	$sp2m | 
	$sp2f | 
	$sp3m | 
	$sp3f | 
	$sp4m | 
	$sp4f | 
	$sp5m | 
	$sp5f | 
	$sp6m | 
	$sp6f | 
	$sm1m | 
	$sm1f | 
	$sm2m | 
	$sm2f | 
	$sm3m | 
	$sm3f | 
	$sm4m | 
	$sm4f | 
	$sm5m | 
	$sm5f | 
	$sm6m | 
	$sm6f | 
	$tallm | 
	$tallf | 
	$tall | 
กลับ";
?>