-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatistic.php
More file actions
52 lines (46 loc) · 1.07 KB
/
Copy pathstatistic.php
File metadata and controls
52 lines (46 loc) · 1.07 KB
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
<?php
$link = mysql_connect("db.coding4coffee.org", "faldi_cuteinbox", "xzbjme6PfM3xKHuX");
mysql_select_db("faldi_cuteinbox", $link);
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $link);
// Tag --> Anzahl
$tags = array();
$res = mysql_query("SELECT comment FROM post");
$number_of_posts = mysql_num_rows($res);
while($row = mysql_fetch_row($res)) {
preg_match_all('/#[\w_\düäöÜÄÖ]+/', $row[0], $matches);
foreach($matches[0] as $val) {
if(isset($tags[$val])) {
$tags[$val]++;
} else {
$tags[$val] = 1;
}
}
}
arsort($tags);
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8"/>
<link href="statistic.css" rel="stylesheet"/>
</head>
<body>
<h4>Tags nach Häufigkeit</h4>
<p>Gesamte Posts: <?=$number_of_posts?></p>
<table>
<thead>
<tr>
<td>Tag</td>
<td>Vorkommen</td>
</tr>
</thead>
<tbody>
<?
foreach($tags as $key => $val) {
echo "<tr><td>$key</td><td>$val</td></tr>";
}
?>
</tbody>
</table>
</body>
</html>