From 61ced3e42a77e624e2209a94c5f324a2071eef7d Mon Sep 17 00:00:00 2001
From: Arun Persaud
These kind of games have been played this often:
";
-$result = DB_query("SELECT COUNT(*) as c,type from Game".
- " WHERE status='gameover'".
- " GROUP BY type".
- " ORDER BY c DESC");
-while( $r = DB_fetch_array($result))
- echo "".$r[1]." (".$r[0].")
";
+$result = DB_query_array_all("SELECT type,COUNT(*) as c from Game".
+ " WHERE status='gameover'".
+ " GROUP BY type".
+ " ORDER BY c DESC");
+array_unshift($result,array("Type","Frequency"));
+echo output_table($result,"stats");
echo "
These kind of solos have been played this often:
";
-$result = DB_query("SELECT COUNT(*) as c,solo from Game".
- " WHERE status='gameover'".
- " AND type='solo'".
- " GROUP BY solo".
- " ORDER BY c DESC");
-while( $r = DB_fetch_array($result))
- echo "".$r[1]." (".$r[0].")
";
+$result = DB_query_array_all("SELECT solo,COUNT(*) as c from Game".
+ " WHERE status='gameover'".
+ " AND type='solo'".
+ " GROUP BY solo".
+ " ORDER BY c DESC");
+array_unshift($result,array("Type","Frequency"));
+echo output_table($result,"stats");
echo "
Most extra points (doko, fox, karlchen) in a single game:
\n";
-$result = DB_query("SELECT COUNT(*) as c,fullname FROM Score".
- " LEFT JOIN User ON User.id=winner_id" .
- " WHERE score IN ('fox','doko','karlchen')".
- " GROUP BY game_id,fullname".
- " ORDER BY c DESC LIMIT 3" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
+$result = DB_query_array_all("SELECT fullname,COUNT(*) as c FROM Score".
+ " LEFT JOIN User ON User.id=winner_id" .
+ " WHERE score IN ('fox','doko','karlchen')".
+ " GROUP BY game_id,fullname".
+ " ORDER BY c DESC LIMIT 3" );
+array_unshift($result,array("Name","Points"));
+echo output_table($result,"stats");
echo "
These players got the most reminders per game:
\n";
-$result = DB_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname FROM Reminder".
- " LEFT JOIN User ON User.id=user_id".
- " GROUP BY user_id".
- " ORDER BY c DESC LIMIT 5" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
+$result = DB_query_array_all("SELECT fullname, COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c".
+ " FROM Reminder".
+ " LEFT JOIN User ON User.id=user_id".
+ " GROUP BY user_id".
+ " ORDER BY c DESC LIMIT 5" );
+array_unshift($result,array("Name","Reminders"));
+echo output_table($result,"stats");
echo "
These players caught the most foxes per game:
\n";
-$result = DB_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname".
- " FROM Score".
- " LEFT JOIN User ON User.id=winner_id".
- " WHERE score='fox'".
- " GROUP BY winner_id".
- " ORDER BY c DESC LIMIT 5" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
+$result = DB_query_array_all("SELECT fullname, COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c".
+ " FROM Score".
+ " LEFT JOIN User ON User.id=winner_id".
+ " WHERE score='fox'".
+ " GROUP BY winner_id".
+ " ORDER BY c DESC LIMIT 5" );
+array_unshift($result,array("Name","Number of foxes caught"));
+echo output_table($result,"stats");
echo "
These players lost their fox most often per game:
\n";
-$result = DB_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname".
- " FROM Score".
- " LEFT JOIN User ON User.id=looser_id".
- " WHERE score='fox'".
- " GROUP BY looser_id".
- " ORDER BY c DESC LIMIT 5" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
+$result = DB_query_array_all("SELECT fullname, COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c".
+ " FROM Score".
+ " LEFT JOIN User ON User.id=looser_id".
+ " WHERE score='fox'".
+ " GROUP BY looser_id".
+ " ORDER BY c DESC LIMIT 5" );
+array_unshift($result,array("Name","Number of foxes lost"));
+echo output_table($result,"stats");
echo "
These players lost their fox least often per game:
\n";
-$result = DB_query("SELECT COUNT(*) /" .
- " (SELECT COUNT(*) FROM Hand".
- " WHERE user_id=User.id) as c,".
- " fullname".
- " FROM Score".
- " LEFT JOIN User ON User.id=looser_id".
- " WHERE score='fox'".
- " GROUP BY looser_id".
- " ORDER BY c ASC LIMIT 5" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
+$result = DB_query_array_all("SELECT fullname, COUNT(*) /" .
+ " (SELECT COUNT(*) FROM Hand".
+ " WHERE user_id=User.id) as c".
+ " FROM Score".
+ " LEFT JOIN User ON User.id=looser_id".
+ " WHERE score='fox'".
+ " GROUP BY looser_id".
+ " ORDER BY c ASC LIMIT 5" );
+array_unshift($result,array("Name","Number of foxes lost"));
+echo output_table($result,"stats");
echo "
Most games played on the server:
\n";
-$result = DB_query("SELECT COUNT(*) as c, " .
- " fullname FROM Hand".
+$result = DB_query_array_all("SELECT fullname, COUNT(*) as c " .
+ " FROM Hand".
" LEFT JOIN User ON User.id=user_id".
" GROUP BY user_id".
" ORDER BY c DESC LIMIT 7" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
+array_unshift($result,array("Name","Number of games"));
+echo output_table($result,"stats");
echo "
These players are involved in this many active games:
\n";
-$result = DB_query("SELECT COUNT(*) as c, " .
- " fullname FROM Hand".
+$result = DB_query_array_all("SELECT fullname, COUNT(*) as c " .
+ " FROM Hand".
" LEFT JOIN User ON User.id=user_id".
" LEFT JOIN Game ON Game.id=game_id".
" WHERE Game.status<>'gameover'".
" GROUP BY user_id".
" ORDER BY c DESC LIMIT 7" );
-while( $r = DB_fetch_array($result))
- echo $r[1]." (".$r[0].")
\n";
+array_unshift($result,array("Name","Number of active games"));
+echo output_table($result,"stats");
echo "