/
whosonline.php
44 lines (37 loc) · 1.27 KB
/
whosonline.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
<?php
require("config.php");
try
{
$area = 0;
$stmt = $dbh->prepare('SELECT * FROM charinfo WHERE current_area != :area ORDER BY current_area');
$stmt->execute(array('area' => $area));
$result = $stmt->fetchAll();
} catch (Exception $e)
{
/*** if we are here, something has gone wrong with the database ***/
$message = 'We are unable to process your request. Please try again later"';
}
if (count($result))
{
$datasetCount = count($result); // returns count of array items of any array
echo "<h3 class='text-center'>There are currently $datasetCount players online on $servername</h3>";
echo '<table id="sortonline" class="table table-condensed table-striped toplist">
<thead>
<tr>
<th style="width: 25%">Character name:</th>
<th style="width: 10%">Level:</th>
</tr></thead>';
foreach ($result as $row)
{
$exp = floor(pow($row['experience'] + 1, 1 / 4));
$curr_area = $row['current_area'];
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $exp . "</td>";
}
} else
{
echo '<h3> Nobodies currently online boiisss </h3>';
}
?>
<?php include_once("analytics.php") ?>