From: Arun Persaud Date: Mon, 26 May 2008 18:22:55 +0000 (-0700) Subject: LAYOUT: applied new table output to statistics page X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=commitdiff_plain;h=61ced3e42a77e624e2209a94c5f324a2071eef7d LAYOUT: applied new table output to statistics page most table on the statistics page should look nice now ;) Signed-off-by: Arun Persaud --- diff --git a/css/standard004.css b/css/standard004.css index e3692af..a568441 100644 --- a/css/standard004.css +++ b/css/standard004.css @@ -460,19 +460,19 @@ table.score { font-size:larger; } -table { margin: 0.5em 1em; +table.stats { margin: 0.5em 1em; border: solid 0.2em #aeaeae; -moz-border-radius: 0.5em ; } -tr.odd { background-color:#aeaeae; } -tr.even { background-color:#eaeaea; } -td,th { +table.stats tr.odd { background-color:#aeaeae; } +table.stats tr.even { background-color:#eaeaea; } +table.stats td, table.stats th { margin-left: 0.2em; margin-right: 0.2em; padding-left: 0.2em; padding-right: 0.2em; border-right: solid 0.1em black; } -tr td:last-child, tr th:last-child { border-right: solid 0 black; } +table.stats tr td:last-child, table.stats tr th:last-child { border-right: solid 0 black; } -th { border-bottom: solid 0.2em black } \ No newline at end of file +table.stats th { border-bottom: solid 0.2em black } \ No newline at end of file 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";