hello,
I display a graph with 2 columns in bars for 2023, 2022, 2021…. If I give static data, the graph displays perfectly fine!
Unfortunately, I am unable to display data from my database, I am still missing information to properly build my 2 Arrays!
Here is what I did:
while ($data = $requete3->fetch()) {
// Hébergement :
if ($data['P_TYPE']=="HEBERGEMENT"){
if(isset($annee) AND ($annee-$data['ANNEE']>=1)){
$restauration[] = array("label"=> $data['ANNEE'], "y"=> 0);
$annee='';
}
else{
$hebergement[] = array("label"=> $data['ANNEE'], "y"=> $data['ca_total']);
$annee=$data['ANNEE'];
}
}
// Hébergement :
if ($data['P_TYPE']=="RESTAURATION"){
if(isset($annee) AND ($annee-$data['ANNEE']>=1)){
$hebergement[] = array("label"=> $data['ANNEE'], "y"=> 0);
$annee='';
}
else{
$restauration[] = array("label"=> $data['ANNEE'], "y"=> $data['ca_total']);
$annee=$data['ANNEE'];
}
}
}
And this is the print_r :
Array
(
[0] => Array
(
[label] => 2023
[y] => 2200.0000
)
)
Array
(
[0] => Array
(
[label] => 2022
[y] => 0
)
[1] => Array
(
[label] => 2022
[y] => 12944.5000
)
)
Thanks for your help
-
This topic was modified 2 years, 4 months ago by stephem69.