2002-11-08 22:30:13 +00:00
|
|
|
<?php
|
|
|
|
require_once("util.inc");
|
|
|
|
require_once("user.inc");
|
|
|
|
|
2002-11-11 19:40:22 +00:00
|
|
|
function team_table_start() {
|
2002-12-06 21:37:30 +00:00
|
|
|
echo VISTABLE."
|
2002-12-13 00:12:44 +00:00
|
|
|
<tr><th>Name</th><th>Members</th><th>Average credit</th><th>Total credit</th>
|
2002-11-11 19:40:22 +00:00
|
|
|
<th>Founded</th></tr>";
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_team_row($team) {
|
|
|
|
echo "<tr>
|
2002-11-12 17:01:16 +00:00
|
|
|
<td><a href=team_display.php?id=$team->id>$team->name</a></td>
|
2002-12-13 00:12:44 +00:00
|
|
|
<td>$team->nusers</td>
|
2002-11-11 19:40:22 +00:00
|
|
|
<td>$team->expavg_credit</td>
|
|
|
|
<td>$team->total_credit</td>
|
|
|
|
<td>".time_str($team->create_time)."</td>
|
|
|
|
<tr>\n";
|
|
|
|
}
|
|
|
|
|
2002-11-08 22:30:13 +00:00
|
|
|
db_init();
|
2002-11-11 19:40:22 +00:00
|
|
|
|
|
|
|
// update team stats; eventually this must be moved
|
|
|
|
// to a separate program
|
|
|
|
//
|
|
|
|
$result = mysql_query("select * from team");
|
|
|
|
while ($team = mysql_fetch_object($result)) {
|
|
|
|
$query = "select sum(total_credit) from user where teamid = $team->id";
|
2002-11-12 17:01:16 +00:00
|
|
|
$result2 = mysql_query($query);
|
|
|
|
$total_credit_sum = mysql_result($result2, 0);
|
2002-11-11 19:40:22 +00:00
|
|
|
|
|
|
|
$query = "select sum(expavg_credit) from user where teamid = $team->id";
|
2002-11-12 17:01:16 +00:00
|
|
|
$result2 = mysql_query($query);
|
|
|
|
$expavg_credit_sum = mysql_result($result2, 0);
|
2002-11-11 19:40:22 +00:00
|
|
|
|
|
|
|
$query = "select count(*) from user where teamid = $team->id";
|
2002-11-12 17:01:16 +00:00
|
|
|
$result2 = mysql_query($query);
|
|
|
|
$nmembers = mysql_result($result2, 0);
|
2002-11-11 19:40:22 +00:00
|
|
|
|
2002-12-16 21:41:41 +00:00
|
|
|
$total_credit = $total_credit_sum;
|
|
|
|
$expavg_credit = $expavg_credit_sum;
|
2002-12-13 00:12:44 +00:00
|
|
|
$query = "update team set nusers=$nmembers, total_credit=$total_credit, expavg_credit=$expavg_credit where id=$team->id";
|
2002-11-12 17:01:16 +00:00
|
|
|
$result2 = mysql_query($query);
|
2002-11-11 19:40:22 +00:00
|
|
|
}
|
|
|
|
mysql_free_result($result);
|
|
|
|
|
2002-11-08 22:30:13 +00:00
|
|
|
page_head("Top teams");
|
2002-12-13 00:12:44 +00:00
|
|
|
$result = mysql_query("select * from team order by expavg_credit desc, total_credit desc");
|
2002-11-08 22:30:13 +00:00
|
|
|
team_table_start();
|
|
|
|
while ($team = mysql_fetch_object($result)) {
|
|
|
|
show_team_row($team);
|
|
|
|
}
|
2002-11-11 19:40:22 +00:00
|
|
|
mysql_free_result($result);
|
2002-12-06 21:37:30 +00:00
|
|
|
echo "</table>\n<p>\n";
|
2002-11-08 22:30:13 +00:00
|
|
|
page_tail();
|
|
|
|
?>
|