-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatteryGUI.php
More file actions
66 lines (60 loc) · 1.77 KB
/
batteryGUI.php
File metadata and controls
66 lines (60 loc) · 1.77 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
////////////////////////////////////// initialise sql variables/////////////////////////////////
$servername = "localhost";
$username = "admin";
$password = "Jayant*1";
$dbname = "NMRL";
////////////Variable list///////////////////////////
///////////////create connnection///////////////////
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql= "SELECT MAX(id) FROM tilt";
$result = $conn->query($sql);
$max_public_date = mysqli_fetch_row($result);
$last_id = $max_public_date[0];
//echo "Latest entry is of the date ".$last_date;
$sql="SELECT * FROM tilt WHERE id=$last_id";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
// output data of each row
while($row = $result->fetch_assoc())
{
$b=$row["battery"];
}
}
else
{
echo " 0 results for array ";
echo $b;
}
?>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Remaining', <?php echo $b;?>],
['Discharge', <?php $b=100-$body;echo $b;?>],
]);
var options = {
title: 'Battery Status',
pieHole: 0.9,
};
var chart = new google.visualization.PieChart(document.getElementById('donutchart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="donutchart" style="width: 900px; height: 500px;"></div>
</body>
</html>