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, count(kd_code) as sendall from tmpkap5,$_sch where kd_sch=scode group by kd_sch order by nrep desc,go desc,sv desc,bn desc,ad desc "; $result=mysql_query($sql); $rk=1; echo <<
ที่ | โรงเรียน | สมัครรวม | ทอง | เงิน | ทองแดง | ชมเชย | รวม | ร้อยละ | ตัวแทน | $rk | $scn | $db[sendall] | $go | $sv | $bn | $ad | $tot | $sper | $rp | TB; $rk++; $tg+=$db[go]; $ts+=$db[sv]; $tb+=$db[bn]; $ta+=$db[ad]; $total+=$tot; $tsend+=$db[sendall]; $trep+=$db[nrep]; } $tsper=number_format($total*100/$tsend,2,'.',','); echo <<รวม CEO $sgr | $tsend | $tg | $ts | $tb | $ta | $total | $tsper | $trep |