-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquery.php
104 lines (81 loc) · 2.44 KB
/
query.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html lang='zh-cn'>
<head>
<title>ZheGeQuery</title>
</head>
<body>
<h2>Type in the sever's port you want to query...@example 8888,87888...</h2>
<form method="post" action="">
port:<input type=text name="port"/>
<h3>choose the date...@example 1994/03/13</h3>
date:<input type=text name="date"/>
<br/>
<input type=submit value="Query" />
</form>
</body>
</html>
<?php
//data : 2015-7-2
//author: zhe13
//email : [email protected]
//name : a query interface for zhegedb
//
//查询数据库获得每日付费人数和关卡人数用
header('content-type:text/html;charset = utf-8');
date_default_timezone_set("PRC");
require "connect.php";
$port=$_POST['port'];
//start query
if($_POST['date']){
$date=$_POST['date'];
}else{
$date=date("Y/m/d",strtotime("-1 day"));
}
echo("<br/>port:$port<br/>date:$date<br/>");
$sql = "SELECT DISTINCT name FROM `".$date."-".$port."action` ORDER BY convert(name using gbk)";
$result = mysql_query($sql);
//get num
$rowCount = mysql_num_rows($result);
echo "number of player is $rowCount<br/>";
getPayNum($rowCount);
getTaskNum();
function getPayNum($totalNum){
global $date,$port;
$sql2 = "SELECT DISTINCT name FROM `".$date."-".$port."action` WHERE action=\"游戏充值\" order by convert(name using gbk)";
$result2 = mysql_query($sql2);
//get num
$rowCount2 = mysql_num_rows($result2);
$rate = $rowCount2/$totalNum;
echo "<br/>number of player who paid is $rowCount2<br/>";
echo "payRate is $rate<br/>";
listPlayer('payPlayr',$result2);
}
function listPlayer($tableName,$result){
//list players
echo "<table border='1'>
<tr>
<th>$tableName</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
//查询各个task的留存人数
function getTaskNum(){
global $date,$port;
$taskId = file("taskId.log");
for($x=0;$x<count($taskId);$x++){
$task = rtrim($taskId[$x]);
$sql = "SELECT DISTINCT name FROM `".$date."-".$port."action` WHERE string LIKE '%".$task."%'";
$result = mysql_query($sql) or die(mysql_error());
$playerNum = mysql_num_rows($result);
echo("$task:$playerNum<br/>");
}
//echo count($row);//check sum
}
mysql_close($conn);
?>