your help is very appreciated.
I am trying to generate a highcharts line graph from data I have stored in a mysql database called "log", said database has different tables each with 5 fields: fecha_id (type date) hora_id (type time) ping_id (type float) timechar_id (type varchar) and pingchar_id (type varchar). I try to select the table, the date and time rows from which I wish to use the data using the POST method, then generate valid data for highcharts to use, I am trying to use the time as X axis and the ping value as y axis. As Deep3015 suggested, I edited my code to followthe guide posted on highchart's website, the (updated) code is:
<?php
require('conexionBD.php');
$depar = $_POST['dto'];
$date = $_POST['fecha'];
$ini = $_POST['hini'];
$fin = $_POST['hfin'];
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts test</title>
<style type="text/css">
</style>
</head>
<body>
<script src="code/highcharts.js"></script>
<script src="code/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<script type="text/javascript">
<?php
$sql = "select * from ".$depar" where fecha_id = '".$date"' and hora_id >= '".$ini"' and hora_id <= '".$fin"'";
$result = $conn->query($sql);
while ($row = mysql_fetch_array($result)) {
$data[] = $row['timechar_id'];
$data1[] = $row['pingchar_id'];
}
?>
Highcharts.chart('container', {
chart: {
type: 'line'
},
title: {
text: 'Ping stats'
},
subtitle: {
text: 'Logged on MySQL'
},
xAxis: {
categories: [<?php echo join($data, ',') ?>]
},
yAxis: {
title: {
text: 'Time in [ms]'
}
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: false
}
},
series: [{
name: 'LPZ',
data: [<?php echo join($data1, ',') ?>]
}]
});
</script>
</body>
</html>
I still get a blank page. So I'd like to know what I'm doing wrong. Thanks for helping me out.
<?= echo $fila['pingchar_id']?>,