"; include('db_config.php'); mysql_query("TRUNCATE TABLE tmpkap2"); mysql_query("insert into tmpkap2 (SELECT * FROM $_data where g+s+b>0 group by kd_sch,kd_code,g,s,b)"); $sql="select kd_code, kd_sch,sname,scode,abb_sch,sum(g) as go,sum(s) as sv,sum(b) as bn from tmpkap2,$_sch where kd_sch=scode group by scode order by go DESC,sv DESC,bn DESC limit 0,10"; $result=mysql_query($sql); echo "
ผลแข่งขัน$_title"; echo ""; echo ""; $row=1; while ($db=mysql_fetch_array($result)) { $total=$db[go]+$db[sv]+$db[bn]; $sql2="select kd_remark,kd_code,kd_sch from $_data where kd_sch='$db[scode]' and kd_remark='1' group by kd_code,kd_sch"; $result2=mysql_query($sql2); $rep=mysql_num_rows($result2); if ($db[go]>0) { $gg=$db[go]; } else { $gg='-'; } if ($db[sv]>0) { $ss=$db[sv]; } else { $ss='-'; } if ($db[bn]>0) { $bb=$db[bn]; } else { $bb='-'; } if ($rep>0) { $rr="$rep"; } else { $rr='-'; } if ($total>0) { $tot=$total; } else { $tot='-'; } echo ""; $row++ ; } echo "
ที่ โรงเรียน รวม ตัวแทน CEO
$row $db[sname] $gg $ss $bb $tot $rr $db[abb_sch]
[ อับเดทล่าสุด ] [ ดูเหรียญรางวัลทุกโรงเรียน ]
"; ?>