"; include('db_config.php'); // $sql="select * from $_reg"; mysql_query("TRUNCATE TABLE mk1"); mysql_query("insert into mk1 (SELECT * FROM $_data group by kd_sch,kd_code,g,s,b)"); $sql="SELECT *,sum(g) AS go,sum(s) AS sv,sum(b) AS bn FROM mk1,$_reg WHERE kd_sch=scode GROUP BY scode ORDER BY go DESC,sv desc,bn desc"; $result=mysql_query($sql); echo "$_title ѧѴ ʾ."; echo ""; echo ""; $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[eef2010]) { $adv=""; $col="#669900"; $dif=abs($row-$db[eef2010]); } elseif ($row>$db[eef2010]) { $col="#FF0000"; $dif=abs($row-$db[eef2010]); $adv=""; } elseif ($row=$db[eef2010]) { $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=""; } */ echo ""; $row++ ; $tg+=$db[go]; $ts+=$db[sv]; $tb+=$db[bn]; $tts+=$total; } $tt=$tg+$ts+$tb ; echo ""; echo "
ʾ. ͧ Թ ͧᴧ 1 2 3
$row $db[sname] $db[go]$db[sv] $db[bn] $total $rnk1 $rnk2 $rnk3 $trp
$tg $ts $tb $tt  

Ũҡ << esan61.net >> "; mysql_close(); ?>