forked from loon3/fldc-stats
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetdata.php
43 lines (28 loc) · 772 Bytes
/
getdata.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
<?php
//load database
require_once "db.php";
//get daily stats per defined URL 'date' parameter
$tablename=$_GET["date"];
$con=mysqli_connect($dbserver, $dbuser, $dbpassword, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query = "SELECT * FROM `".$tablename."`";
$result = mysqli_query($con, $query);
$i = 0;
while($row = @mysqli_fetch_array($result))
{
//id name token address totalpts
$data[$i]['id'] = $row['id'];
$data[$i]['name'] = $row['name'];
$data[$i]['token'] = $row['token'];
$data[$i]['address'] = $row['address'];
$data[$i]['newcredit'] = $row['totalpts'];
$i++;
}
mysqli_close($con);
//show daily stats as JSON
echo json_encode($data);
?>