"; include('db_config.php'); mysql_query("TRUNCATE TABLE tmpao5"); mysql_query("insert into tmpao5 (SELECT * FROM $_tdata group by kd_sch,kd_code,g,s,b,kd_sp)"); $sql="select *,left(kp_code,2) as gr,sum(g) as g,sum(s) as s,sum(b) as b from tmpao5,$_tact where kp_code=kd_code group by gr order by kp_grp"; $result=mysql_query($sql); echo "
ผลการประกวดสื่อนวัตกรรมครู "; $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_code],0,2); $sql3="select * from $_tdata,$_sch where kd_sch=scode and kd_code like '$kgp%' and kd_rank='1' "; $result3=mysql_query($sql3); $db3=mysql_fetch_array($result3); if ($kgp=='dv') { $srp='-'; } else { $srp=$db3[sname]; } 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 ""; $tg+=$db[g]; $ts+=$db[s]; $tb+=$db[b]; $ta+=$db[a]; $total+=$tt; $rw++; } echo "
ที่ กลุ่มสาระ
การเรียนรู้
รวม ตัวแทน อบจ.
$rw $db[kp_grp] $gg $ss $bb $tot $srp
รวม $tg $ts $tb $total $trp
"; ?>