OSDN Git Service

[modify]人気ランキングのページから該当スコアランキングへのリンクを貼る
[hengband/web.git] / popularity_ranking.php
1 <?php
2 //ini_set('display_errors', 'On');
3
4 ini_set('log_errors', 'On');
5 ini_set('error_log', 'errors/'.pathinfo(__FILE__, PATHINFO_FILENAME).'.log');
6
7 ini_set('zlib.output_compression', 'On');
8
9 include "db_common.inc";
10
11 function print_popularity_table($stat, $id_name, $name)
12 {
13     echo <<<EOM
14 <table>
15 <tr>
16 <th>#</th>
17 <th>$name</th>
18 <th>計</th>
19 <th>男性</th>
20 <th>女性</th>
21 <th>勝利</th>
22 <th>平均スコア</th>
23 <th>最大スコア</th>
24 </tr>
25
26 EOM;
27
28     $rank = 0;
29     foreach ($stat as $k => $s) {
30         $rank ++;
31         $name_link = "<a href='score_ranking.php?{$id_name}={$s['id']}'>{$s['name']}</a></td>";
32         $average_score = floor($s['average_score']);
33         echo <<<EOM
34 <tr>
35 <td>$rank</td>
36 <td>$name_link</td>
37 <td>{$s['total_count']}</td>
38 <td>{$s['male_count']}</td>
39 <td>{$s['female_count']}</td>
40 <td>{$s['winner_count']}</td>
41 <td>$average_score</td>
42 <td>{$s['max_score']}</td>
43 </tr>
44 EOM;
45     }
46
47     echo "</table>";
48 }
49
50
51 $db = new ScoreDB();
52
53 $time_start = microtime(true);
54
55 $statistics = $db->get_statistics_tables();
56
57 $query_time = microtime(true) - $time_start;
58 ?>
59
60 <!DOCTYPE html>
61 <html>
62 <head>
63 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
64 <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
65 <title>変愚蛮怒 人気のある種族・職業・性格</title>
66 </head>
67
68 <small>
69 <?php
70 echo sprintf("(%.2f 秒)", $query_time);
71 ?>
72 </small>
73 <hr>
74 <h1>人気のある種族</h1>
75
76 <?php
77 print_popularity_table($statistics['race'], 'race_id', "種族");
78 ?>
79
80 <hr>
81 <h1>人気のある職業</h1>
82
83 <?php
84 print_popularity_table($statistics['class'], 'class_id', "職業");
85 ?>
86
87 <hr>
88 <h1>人気のある性格</h1>
89
90 <?php
91 print_popularity_table($statistics['personality'], 'personality_id', "性格");
92 ?>