"; global $scid; include('db_config.php'); $sql0="select scode,sname,sgrp from $_reg where scode='$scid'" ; $result0=mysql_query($sql0); $db0=mysql_fetch_array($result0); $scname=$db0[sname]; $sgrp=$db0[sgrp]; $sql="SELECT * FROM $_act,$_data WHERE kd_code=kp_code and kd_sch='$scid' and g+s+b>0 order by g desc,s desc,b desc,kd_school,kd_code"; $result=mysql_query($sql); echo "สรุปเหรียญรางวัล แยกประเภท สพป.$scname $_title"; echo ""; echo ""; $gr=''; $ac=''; $md=''; $rp=''; $sc=''; while ($db=mysql_fetch_array($result)) { if ($db[g]>0) { $medal='ทอง'; $col='#FFFF99'; // $type=$db[g]; } elseif ($db[s]>0) { $medal='เงิน'; $col='#DDDDFF'; // $type=$db[s]; } elseif ($db[b]>0) { $medal='ทองแดง'; $col='#FFD9E9'; // $type=$db[b]; } elseif ($db[a]>0) { $medal='ชมเชย'; $col='#DFFFFF'; // $type=$db[b]; } if ($db[kd_rank]<4) { $rem=""; } else { $rem=""; } if ($db[kp_grp]==$gr) { if ($db[kd_code] ==$ac) { $gp=" "; } else { $gp="$db[kp_grp]"; } } else { $gp="$db[kp_grp]"; } if ($db[kd_code] ==$ac) { $act=" "; } else { $act="$db[kp_act] ($db[kp_level])"; } if ($medal==$md) { if ($db[kd_code]==$ac) { $med=" "; // $psc=" "; } else { $med="$medal"; // $psc="พิมพ์ รร."; } } else { $med="$medal"; // $psc="พิมพ์ รร."; } if ($db[kd_ed]=='2') { $rmk="แจ้งแล้ว"; } elseif($db[kd_ed]=='1') { $rmk="รอแก้ไข"; } else { $rmk="แจ้งแก้ไข"; } /* $sql2="select * from $_sc where scc='$db[kd_school]' "; $result2=mysql_query($sql2); $db2=mysql_fetch_array($result2); $scm=$db2[scn]; */ echo " $rem "; $ac=$db[kd_code]; $gr=$db[kp_grp]; $md=$medal; $sc=$db[kd_sch]; } echo "
เหรียญ กิจกรรม โรงเรียน ตัวแทนภาคฯ
ตัวแทน 
$med $db[kp_act] $db[kd_school]
"; mysql_close(); ?>