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,a)");
$sql="select *,sum(kd_remark) as nrep,sum(g) as go,sum(s) as sv,sum(b) as bn,sum(a) as ad
from tmpkap5,$_sch where kd_sch=scode group by kd_sch
order by nrep desc,go desc,sv desc,bn desc,ad desc limit 0,16";
$result=mysql_query($sql);
echo <<
สรุปแยกโรงเรียน เรียงตามจำนวนตัวแทน สพป.
ที่
โรงเรียน
ตัวแทน
CEO
TH;
$rk=1;
while ($db=mysql_fetch_array($result)) {
$scname=substr($db[sname],0,24);
$sper=number_format($db[allmed]*100/$db[sendall],2,'.',',');
echo <<