Hi, I am new, mixing php in javascript. I would like to know how I can adapt this foreach well in this javascript statement so that the information is displayed correctly.
$consulta= $obj->getQueryConsulta();
$result = $catalogo->obtenerLista($consulta);
$datos = array();
while ($row = mysql_fetch_array($result)) {
$datos[$row['datos']] = $row['series'];
}
echo "<script>Highcharts.chart('container', {
title: {
text: '".$obj->getDescripcion()."'
},
subtitle: {
text: 'Source: thesolarfoundation.com'
},
yAxis: {
title: {
text: '".$obj->getDescripcion()."'
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: 2010
}
},
series: [
". foreach ($datos as $key => $value) {
"{"
" name: '".$key."',
data: [".for ($index = 0; $index < 12; $index++) {
"$value[$index],]"
}
}
" }],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
}); </script>";
break;
la sentencia original de javascript es esta
series: [{
name: 'Installation',
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
}],