header('Content-Type: text/html; charset=tis-620');
include('../db_config.php');
$sql="select *,count(*) as nsc from sch where onetb='1' group by scgrp order by sampur";
$result=mysql_query($sql);
echo "
ที่ |
กลุ่มโรงเรียน |
ทั้งหมด |
ตอบแล้ว |
ร้อยละ |
";
$rw=1; $gsc=0;
while ($db=mysql_fetch_array($result)) {
$sql2="select * from sk1_onetb a,sch b where a.scode=b.scode and b.scgrp='$db[scgrp]'
group by a.scode";
$result2=mysql_query($sql2);
$gsc=mysql_num_rows($result2);
if ($gsc>0) { $gg=$gsc; } else { $gg='-'; }
$perc=number_format($gsc*100/$db[nsc],2,'.','');
echo "
$rw |
$db[sgrp] |
$db[nsc] |
$gg |
$perc |
";
$rw++; $tgsc+=$gsc; $gsc=0; $tnsc+=$db[nsc];
}
$tperc=number_format($tgsc*100/$tnsc,2,'.','');
echo <<
รวม |
$tnsc |
$tgsc |
$tperc |
TF;
?>