$reg=$_GET["reg"];
header('Content-Type: text/html; charset=tis-620');
echo " ";
include('db_config.php');
$sql0="select scode,sname from $_reg where scode='$reg'" ;
$result0=mysql_query($sql0);
$db0=mysql_fetch_array($result0);
$scname=$db0[sname];
$sql="SELECT * FROM $_act,$_data
WHERE kd_code=kp_code and kd_sch='$reg' and g+s+b+a>0
order by g desc,s desc,b desc,kp_act";
$result=mysql_query($sql);
echo "
สรุปเหรียญรางวัล $_title แยกประเภท สพป. $scname
เหรียญ
กิจกรรม
คะแนน
โรงเรียน
หมายเหตุ
แจ้งแก้ไข
";
$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]";
}
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 scid,scname from $_sch where scid='$db[kd_school]' ";
$result2=mysql_query($sql2);
$db2=mysql_fetch_array($result2);
$scm=substr($db[kd_school],0,50);
$kcode=substr($db[kd_code],3,3);
echo "
$med
$kcode $db[kp_act]
$db[kd_score]
$scm
$db[kd_remark]
$rmk
";
$ac=$db[kd_code]; $gr=$db[kp_grp]; $md=$medal; $sc=$db[kd_sch];
}
echo "
";
?>