header('Content-Type: text/html; charset=tis-620');
echo "";
include('db_config.php');
mysql_query("TRUNCATE TABLE tmpkap1");
mysql_query("insert into tmpkap1 (SELECT * FROM $_data
group by kd_sch,kd_code,g,s,b)");
$sql="select *,sum(g) as g,sum(s) as s,sum(b) as b
from tmpkap1,$_act where kp_id=kd_code group by kp_cd order by kp_grp";
$result=mysql_query($sql);
echo "
สรุปเหรียญรางวัล แยกรายกิจกรรม $_title";
echo "
";
echo "
ที่
กลุ่มสาระการเรียนรู้
1
2
3
รวม
ตัวแทน CEO
";
$tg=0; $ts=0; $tb=0; $ta=0; $total=0; $rw=1; $kgp='';
while ($db=mysql_fetch_array($result)) {
$tt=$db[g]+$db[s]+$db[b];
$kgp=substr($db[kd_id],0,2);
if ($db[g]>0) { $gg=$db[g]; } else { $gg='-'; }
if ($db[s]>0) { $ss=$db[s]; } else { $ss='-'; }
if ($db[b]>0) { $bb=$db[b]; } else { $bb='-'; }
if ($rep>0) { $rr=$rep; } else { $rr='-'; }
if ($tt>0) { $tot=$tt; } else { $tot='-'; }
echo "