<?PHP
include "config.php";for($i=0; $i<=6; $i++){
$dato=date('Y-m-d',strtotime("-".$i." days"));$hent=mysqli_query($con,"SELECT * FROM WithdrawalLog WHERE tid LIKE '%".$dato."%' AND Location='Location1' ORDER BY id DESC LIMIT 0, 1000");while($row=mysqli_fetch_array($hent)){$amount=abs($row["antalLiter"]);$loction1=$location1+$amount;}
$hent=mysqli_query($con,"SELECT * FROM WithdrawalLog WHERE tid LIKE '%".$dato."%' AND Location='Location2' ORDER BY id DESC LIMIT 0, 1000");while($row=mysqli_fetch_array($hent)){$amount=abs($row["antalLiter"]);
$location1=$location1+$amount;
}$resultat .= "['".$dato."', '".$location1."','".$location2."'],";$location1=0;$location2=0;}?><html><head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['bar']}); google.charts.setOnLoadCallback(drawChart);
function drawChart() { var data = google.visualization.arrayToDataTable([ ['Dato', 'Location1', 'Location2'],
<?PHPecho $resultat;?> ]);
var options = { chart: { title: 'Last 7 days', subtitle: 'Date and location', }
};
var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
chart.draw(data, google.charts.Bar.convertOptions(options)); } </script>
<meta http-equiv="refresh" content="60" >
<meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body>
<div id="columnchart_material" style="width: 90%; margin:auto; height: 500px;"></div>
</body></html>Here is how the chart is processed..