สรุปเหรียญ $_titlereg "; $row=1; $tg=0; $ts=0; $tb=0; $ag=''; while ($db=mysql_fetch_array($result)) { $total=$db[go]+$db[sv]+$db[bn]; if ($total==0) { $tt='-'; } else { $tt=$total; } if ($db[go]==0) { $gg='-'; } else { $gg=$db[go]; } if ($db[sv]==0) { $ss='-'; } else { $ss=$db[sv]; } if ($db[bn]==0) { $bb='-'; } else { $bb=$db[bn]; } $sql2="select kd_sp,kd_code,kd_sch from $_reg where kd_sch='$db[scode]' and kd_rank='1' group by kd_code,kd_sch"; $result2=mysql_query($sql2); $fr=mysql_num_rows($result2); $sql2="select kd_sp,kd_code,kd_sch from $_reg where kd_sch='$db[scode]' and kd_rank='2' group by kd_code,kd_sch"; $result2=mysql_query($sql2); $nd=mysql_num_rows($result2); $sql2="select kd_sp,kd_code,kd_sch from $_reg where kd_sch='$db[scode]' and kd_rank='3' group by kd_code,kd_sch"; $result2=mysql_query($sql2); $rd=mysql_num_rows($result2); $sql3="select * from $_reg where kd_remark=1 and kd_sch='$db[scode]' group by kd_code"; $result3=mysql_query($sql3); $rep0=mysql_num_rows($result3); $sql4="select * from $_reg where kd_rank in (1,2,3) and kd_sch='$db[scode]' group by kd_code"; $result4=mysql_query($sql4); $regrp=mysql_num_rows($result4); if ($fr>0) { $frr="$fr"; } else { $frr='-'; } if ($nd>0) { $fnd="$nd"; } else { $fnd='-'; } if ($rd>0) { $frd="$rd"; } else { $frd='-'; } if ($rep0>0) { $rr0="$rep0"; } else { $rr0='-'; } if ($regrp>0) { $rr="$regrp"; } else { $rr='-'; } if ($db[sgrp]=='ก่อน/ประถม') { if ($sg!==$db[sgrp]) { $row=1; } $cl='#ddeeff'; } elseif ($db[sgrp]=='ขยายโอกาส') { if ($sg!=$db[sgrp]) { $row=1; } $cl='#cce6ff'; } else { if ($sg!=$db[sgrp]) { $row=1; } $cl='#b7dbff'; } echo ""; $row++; $trep+=$rep0; $tg+=$db[go]; $ts+=$db[sv]; $tb+=$db[bn]; $sg=$db[sgrp]; $sst+=$fr; $snd+=$nd; $srd+=$rd; } $ttm=$tg+$ts+$tb; $tss=$sst+$snd+$srd; echo "
ลำดับ โรงเรียน ประเภท ตัวแทน
อบจ.
รวม ชนะ
เลิศ
ที่ 2 ที่ 3 ตัวแทน
ภาคฯ
เข้าระบบ
$row $db[sname] $db[sgrp] $rr0 $gg $ss $bb $tt $frr $fnd $frd $rr รายงานผล
รวม $trep $tg $ts $tb $ttm $sst $snd $srd $tss  
"; ?>