For styling a web page, I often use the highcharts graphics with information from a mysql database via php. For those unfamiliar with highcharts, here's a sample code below.
Highcharts.chart('minhadiv', {
chart: {
type: 'bar'
},
xAxis: {
categories: ['Categoria 1', 'Categoria 2', 'Categoria 3'],
},
series: [{
name: 'Informação',
data: [1, 2, 3]
}]
});
This code returns me a graph like this:
Ialwaysmakethephpconnectionwithmysqlwithinthedata
field,anditissuccessful.HereisanexampleofansqlconnectionI'veusedbefore:
data:[<?php$mysqli=newmysqli('servidor','usuario','senha','banco');$sql=$mysqli->query("SELECT minhacoluna from minhatabela");
?>
<?php while ($result = mysqli_fetch_array($sql)) {?>
<?php echo $result["minhacoluna"]?>,
<?php } ?>],
The problem is that now I needed to make this sql connection in both the data
field and the categories
field, since the categories can change according to my database. When trying to put a php code like the one I normally use, I get no result. How to proceed in this case?