header('Content-Type: text/html; charset=tis-620');
echo "";
include('db_config.php');
mysql_query("TRUNCATE TABLE anb6");
mysql_query("insert into anb6 (SELECT * FROM $_data
group by kd_sch,kd_code,g,s,b,kd_sp)");
$yr=date('y')+43;
$ry='g'.$yr;
$sql="select * from $_sch order by $ry desc";
$result=mysql_query($sql);
include('header.php');
echo "
สรุปเหรียญทอง แยกตามกลุ่มสาระ ";
echo "
";
echo "
ที่
โรงเรียน
จำนวนเหรียญทอง แยกกลุ่มสาระการเรียนรู้
รวม 134
อ.1
อ.2
ไทย
คณิต
วิทย์
สังคมฯ
พละ
ทัศนศิลป์
วาดรูป
การงานฯ
Eng
คอมฯ
10
10
12
12
12
12
12
12
12
12
12
6
";
$row=1; $s1=0; $s2=0; $s3=0; $s4=0; $s5=0; $s6=0; $s7=0; $s8=0; $s9=0; $s10=0; $s11=0; $s12=0; $ts=0;
while ($db=mysql_fetch_array($result)) {
$sql1="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'p1%' and g=1";
$result1=mysql_query($sql1);
$s1=mysql_num_rows($result1);
$sql2="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'p2%' and g=1";
$result2=mysql_query($sql2);
$s2=mysql_num_rows($result2);
$sql3="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'th%' and g=1";
$result3=mysql_query($sql3);
$s3=mysql_num_rows($result3);
$sql4="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'ma%' and g=1";
$result4=mysql_query($sql4);
$s4=mysql_num_rows($result4);
$sql5="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'sc%' and g=1";
$result5=mysql_query($sql5);
$s5=mysql_num_rows($result5);
$sql6="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'so%' and g=1";
$result6=mysql_query($sql6);
$s6=mysql_num_rows($result6);
$sql7="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'pe%' and g=1";
$result7=mysql_query($sql7);
$s7=mysql_num_rows($result7);
$sql8="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'at%' and g=1";
$result8=mysql_query($sql8);
$s8=mysql_num_rows($result8);
$sql9="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'ar%' and g=1";
$result9=mysql_query($sql9);
$s9=mysql_num_rows($result9);
$sql10="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'oc%' and g=1";
$result10=mysql_query($sql10);
$s10=mysql_num_rows($result10);
$sql11="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'en%' and g=1";
$result11=mysql_query($sql11);
$s11=mysql_num_rows($result11);
$sql12="select * from anb6,$_sch,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]'
and kp_code like 'cm%' and g=1";
$result12=mysql_query($sql12);
$s12=mysql_num_rows($result12);
$ts=$s1+$s2+$s3+$s4+$s5+$s6+$s7+$s8+$s9+$s10+$s11+$s12;
if ($s1==0) { $s1='-'; }
if ($s2==0) { $s2='-'; }
if ($s3==0) { $s3='-'; }
if ($s4==0) { $s4='-'; }
if ($s5==0) { $s5='-'; }
if ($s6==0) { $s6='-'; }
if ($s7==0) { $s7='-'; }
if ($s8==0) { $s8='-'; }
if ($s9==0) { $s9='-'; }
if ($s10==0) { $s10='-'; }
if ($s11==0) { $s11='-'; }
if ($s12==0) { $s12='-'; }
if ($ts>0) { $tot=$ts; } else { $tot='-'; }
$res=$row%2;
if ($res==0) { $cl='#FFEBBF'; } else { $cl='#FFEFCE'; }
echo "