header('Content-Type: text/html; charset=tis-620');
echo "";
include('db_config.php');
mysql_query("TRUNCATE TABLE tmpkap5");
mysql_query("insert into tmpkap5 (SELECT * FROM $_data group by kd_sch,kd_code,g,s,b,kd_sp)");
$sql="select * from $_reg order by eef2013 limit 0,10";
$result=mysql_query($sql);
echo "
";
$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 tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='01' and g>0";
$result1=mysql_query($sql1);
$s1=mysql_num_rows($result1);
$sql2="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='02' and g>0";
$result2=mysql_query($sql2);
$s2=mysql_num_rows($result2);
$sql3="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='03' and g>0";
$result3=mysql_query($sql3);
$s3=mysql_num_rows($result3);
$sql4="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and
(kp_cd='04' or kp_cd='15' or kp_cd='16') and g>0";
$result4=mysql_query($sql4);
$s4=mysql_num_rows($result4);
$sql5="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='05' and g>0";
$result5=mysql_query($sql5);
$s5=mysql_num_rows($result5);
$sql6="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='06' and g>0";
$result6=mysql_query($sql6);
$s6=mysql_num_rows($result6);
$sql7="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='07' and g>0";
$result7=mysql_query($sql7);
$s7=mysql_num_rows($result7);
$sql8="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and (kp_cd='08' or kp_cd='09') and g>0";
$result8=mysql_query($sql8);
$s8=mysql_num_rows($result8);
/*
$sql9="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='09' and g>0";
$result9=mysql_query($sql9);
$s9=mysql_num_rows($result9);
*/
$sql10="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='10' and g>0";
$result10=mysql_query($sql10);
$s10=mysql_num_rows($result10);
$sql11="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='11' and g>0";
$result11=mysql_query($sql11);
$s11=mysql_num_rows($result11);
$sql12="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='12' and g>0";
$result12=mysql_query($sql12);
$s12=mysql_num_rows($result12);
$sql13="select * from tmpkap5,$_reg,$_act
WHERE kd_sch=scode and kd_code=kp_code and kd_sch='$db[scode]' and kp_cd='13' and g>0";
$result13=mysql_query($sql13);
$s13=mysql_num_rows($result13);
$ts=$s1+$s2+$s3+$s4+$s5+$s6+$s7+$s8+$s10+$s11+$s12+$s13;
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 ($s10==0) { $s10='-'; }
if ($s11==0) { $s11='-'; }
if ($s12==0) { $s12='-'; }
if ($s13==0) { $s13='-'; }
if ($total>0) { $tot=$total; } else { $tot='-'; }
$res=$row%2;
if ($res==0) { $cl='#FFEBBF'; } else { $cl='#FFEFCE'; }
echo "