header('Content-Type: text/html; charset=tis-620');
echo " ";
include('db_config.php');
// $sql="select * from $_reg";
mysql_query("TRUNCATE TABLE tmpkap6");
mysql_query("insert into tmpkap6 (SELECT * FROM $_data group by kd_sch,kd_code,g,s,b,kd_sp)");
$sql="SELECT *,sum(g) AS go,sum(s) AS sv,sum(b) AS bn
FROM tmpkap6,$_reg WHERE kd_sch=scode
GROUP BY kd_sch ORDER BY go desc,sv desc,bn desc";
$result=mysql_query($sql);
echo "
$_title
<< ÊÃØ»¢éÍÁÙÅâ´Â ʾ».ÈÃÕÊÐà¡É ࢵ ñ >>
·Õè
ʾ».
1
2
3
µÑÇá·¹
Íѹ´Ñº»Õ 55
";
$row=1; $tg=0; $ts=0; $tb=0; $ta=0; $tts=0;
while ($db=mysql_fetch_array($result)) {
$rg=$db[scode];
$sql2="SELECT kd_sch,count(kd_rank) as rk1
FROM $_data WHERE kd_sch='$rg' and kd_rank=1
GROUP BY kd_sch";
$result2=mysql_query($sql2);
$db2=mysql_fetch_array($result2);
$rnk1=$db2[rk1];
$sql2="SELECT kd_sch,count(kd_rank) as rk2
FROM $_data WHERE kd_sch='$rg' and kd_rank=2
GROUP BY kd_sch";
$result2=mysql_query($sql2);
$db2=mysql_fetch_array($result2);
$rnk2=$db2[rk2];
$sql2="SELECT kd_sch,count(kd_rank) as rk3
FROM $_data WHERE kd_sch='$rg' and kd_rank=3
GROUP BY kd_sch";
$result2=mysql_query($sql2);
$db2=mysql_fetch_array($result2);
$rnk3=$db2[rk3];
if ($rnk1+$rnk2+$rnk3>0) {
$trp=$rnk1+$rnk2+$rnk3;
} else {
$trp='-';
}
$total=$db[go]+$db[sv]+$db[bn];
if ($row<$db[eef2012]) {
$adv=" ";
$col="#669900";
$dif=abs($row-$db[eef2012]);
} elseif ($row>$db[eef2012]) {
$col="#FF0000";
$dif=abs($row-$db[eef2012]);
$adv=" ";
} elseif ($row=$db[eef2012]) {
$dif='-';
$adv=" ";
}
/*
if ($row<$db[eef2009]) {
$adv=" ";
$col="#669900";
$dif=abs($row-$db[eef2009]);
} elseif ($row>$db[eef2009]) {
$col="#FF0000";
$dif=abs($row-$db[eef2009]);
$adv=" ";
} elseif ($row=$db[eef2009]) {
$dif='-';
$adv=" ";
}
if ($row<$db[eef2008]) {
$adv0=" ";
$col0="#669900";
$dif0=abs($row-$db[eef2008]);
} elseif ($row>$db[eef2008]) {
$col0="#FF0000";
$dif0=abs($row-$db[eef2008]);
$adv0=" ";
} elseif ($row=$db[eef2008]) {
$dif0='-';
$adv0=" ";
}
*/
if ($rnk1==0) { $rnk1='-'; }
if ($rnk2==0) { $rnk2='-'; }
if ($rnk3==0) { $rnk3='-'; }
echo "
$row
$db[sname]
$db[go] $db[sv]
$db[bn]
$rnk1
$rnk2
$rnk3
$trp
$db[eef2012]
$adv
$dif
";
$row++ ; $tg+=$db[go]; $ts+=$db[sv]; $tb+=$db[bn];
}
// $tt=$tg+$ts+$tb+$ta ;
echo "ÃÇÁ
$tg
$ts
$tb
";
?>