0
Hello,
I have a php file with a div calling the js file, but I need the js file to read the php data
in arquvio php:
<div id="chart_div" style="width: 100%; height: 500px;"></div>
in the js file:
function mainChart(){
var color1 = App.color.primary;
var color2 = tinycolor( App.color.primary ).lighten( 13 ).toString();
var color3 = tinycolor( App.color.primary ).lighten( 20 ).toString();
var data = [
[1, 35],
[2, 60],
[3, 40],
[4, 65],
[5, 45],
[6, 75],
[7, 35],
[8, 40],
[9, 60]
];
instead of this fixed array I have to fetch this data in the Database would look lake like this:
function mainChart(){
var color1 = App.color.primary;
var color2 = tinycolor( App.color.primary ).lighten( 13 ).toString();
var color3 = tinycolor( App.color.primary ).lighten( 20 ).toString();
var data = [
<?php
$i = '0';
foreach ($ConsultasCanceladas as $canceladas) {
$i = ++$i;
echo "['" . $i . "', " . $canceladas->dt_consulta . "],";
}
?>
];
What happens is that the js file does not accept php
Put this mainChart function inside the PHP file, or use AJAX to get this data.
– Kayo Bruno