From 61ced3e42a77e624e2209a94c5f324a2071eef7d Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Mon, 26 May 2008 11:22:55 -0700 Subject: LAYOUT: applied new table output to statistics page most table on the statistics page should look nice now ;) Signed-off-by: Arun Persaud --- include/stats.php | 137 ++++++++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 70 deletions(-) (limited to 'include') diff --git a/include/stats.php b/include/stats.php index eac8a8e..a702a88 100644 --- a/include/stats.php +++ b/include/stats.php @@ -44,23 +44,23 @@ echo " games.

\n"; /* number of solos */ echo "

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 "

\n"; /* break up solos in types */ 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 "

\n"; /* @@ -76,13 +76,13 @@ echo "

\n"; */ 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 "

\n"; /* longest and shortest game */ @@ -118,58 +118,55 @@ if($r) /* most reminders */ 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 "

\n"; /* fox */ 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 "

\n"; 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 "

\n"; 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 "

\n"; /* which position wins the most tricks */ @@ -191,26 +188,26 @@ echo "

\n"; /* most games */ 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 "

\n"; /* most active games */ 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 "

\n"; -- cgit v1.2.3-18-g5258