<?php
require_once("template.php");

$tab= array();

$requete0= "SELECT COUNT(*) FROM `journal` JOIN `aliments` ON `journal`.`id_aliment`=`aliments`.`id_aliment` WHERE `type`='Fruit'";
$rep0=$mysqli->query($requete0);
$result0=$rep0->fetch_all();

$tab[0]=$result0[0][0];

$requete1= "SELECT COUNT(*) FROM `journal` JOIN `aliments` ON `journal`.`id_aliment`=`aliments`.`id_aliment` WHERE `type`='Legume'";
$rep1=$mysqli->query($requete1);
$result1=$rep1->fetch_all();

$tab[1]=$result1[0][0];

$requete2= "SELECT COUNT(*) FROM `journal` JOIN `aliments` ON `journal`.`id_aliment`=`aliments`.`id_aliment` WHERE `type`='Feculent'";
$rep2=$mysqli->query($requete2);
$result2=$rep2->fetch_all();

$tab[2]=$result2[0][0];

$requete3= "SELECT COUNT(*) FROM `journal` JOIN `aliments` ON `journal`.`id_aliment`=`aliments`.`id_aliment` WHERE `type`='Laitage'";
$rep3=$mysqli->query($requete3);
$result3=$rep3->fetch_all();

$tab[3]=$result3[0][0];

$requete4= "SELECT COUNT(*) FROM `journal` JOIN `aliments` ON `journal`.`id_aliment`=`aliments`.`id_aliment` WHERE `type`='Sucrerie'";
$rep4=$mysqli->query($requete4);
$result4=$rep4->fetch_all();

$tab[4]=$result4[0][0];

echo reponse_json($tab);


