Commit e6108cfa authored by Liang Wu's avatar Liang Wu
parents be77a7fb 4b361f4c
......@@ -106,6 +106,8 @@
<select id="cat" name="cat" size="1">
<option value="Fruit"> Fruit </option>
<option value="Legume"> Legume </option>
<option value="Feculent"> Feculent </option>
<option value="Laitage"> Legume </option>
<option value="Sucrerie"> Sucrerie </option>
</select>
......
<?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);
......@@ -15,8 +15,7 @@ if(isset($_GET['page'])){
<header class="masthead bg-primary text-white text-center">
<div class="container d-flex align-items-center flex-column">
<!-- Masthead Heading -->
<!-- <h2 class="masthead-heading text-uppercase mb-0"><?php echo $mymenu[$currentPageId][0] ?></h2> -->
<!-- Masthead Subheading -->
......
<head>
<meta charset="utf-8"/>
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#table_aliments').DataTable();
resetForm();
} );
function resetForm() {
document.getElementById("id").value=""
document.getElementById("aliment").value = "";
document.getElementById("calories").value = "";
document.getElementById("cat").value = "";
document.getElementById("submit_button").value="Ajouter";
};
</script>
<script type="text/javascript">
$(document).ready( function() {
$.getJSON('https://eden.imt-lille-douai.fr/~charlotte.raulin/Projet/api/read_indicateur.php',
function(json){
table = $('#tbody_indicateur');
table.html('');
echo(json);
echo(json[0]);
// cf. https://api.jquery.com/jQuery.getJSON/
// $.each( json, function( key, val ) {
// // table.append('<tr><td>'+val[0]+'</td><td>'+val[1]+'</td><td>'+val[2]+'</td><td><button '+
// // 'onclick="onEdit('+val[0]+',\''+val[1]+'\',\''+val[2]+'\')">Modifier</button></td></tr>');
// table.append('<tr><td>'+val[0]+'</td><td>'+val[1]+'</td><td>'+val[2]+'</td><td>'+val[3]+'</td><td>'+val[4]+'</td></tr>');
// });
}
);
});
</script>
</head>
<div style="margin-right:100px">
<table id="table_indicateur" class="dataTable" style="color : #212529; ">
<thead>
<tr>
<th>Fruit</th>
<th>Legume</th>
<th>Feculent</th>
<th>Laitage</th>
<th>Sucrerie</th>
</tr>
</thead>
<tbody id="tbody_indicateur"><tbody>
</table>
</div>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment