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, $name)
12 {
13     echo <<< EOM
14         <table>
15     <tr>
16     <th>#
17     <th>$name
18     <th>計
19     <th>男性
20     <th>女性
21     <th>勝利
22     <th>平均スコア
23     <th>最大スコア
24     </tr>
25 EOM;
26
27     $rank = 0;
28     foreach ($stat as $s) {
29         $rank ++;
30         $average_score = floor($s['average_score']);
31         echo <<< EOM
32 <tr>
33             <td>$rank</td>
34         <td>{$s['name']}</td>
35         <td>{$s['total_count']}</td>
36         <td>{$s['male_count']}</td>
37         <td>{$s['female_count']}</td>
38         <td>{$s['winner_count']}</td>
39         <td>$average_score</td>
40         <td>{$s['max_score']}</td>
41         </tr>
42 EOM;
43     }
44
45     echo "</table>";
46 }
47
48
49 $db = new ScoreDB();
50
51 $time_start = microtime(true);
52
53 $statistics = $db->get_statistics_tables();
54
55 $query_time = microtime(true) - $time_start;
56 ?>
57
58 <!DOCTYPE html>
59 <html>
60 <head>
61 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
62 <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
63 <title>変愚蛮怒 人気のある種族・職業・性格</title>
64 </head>
65
66 <small>クエリ時間<?php echo sprintf("%.3f msec", $query_time * 1000) ?></small>
67 <hr>
68 <h1>人気のある種族</h1>
69
70 <?php
71 print_popularity_table($statistics['race'], "種族");
72 ?>
73
74 <hr>
75 <h1>人気のある職業</h1>
76
77 <?php
78 print_popularity_table($statistics['class'], "職業");
79 ?>
80
81 <hr>
82 <h1>人気のある性格</h1>
83
84 <?php
85 print_popularity_table($statistics['personality'], "性格");
86 ?>