Skip to content
Snippets Groups Projects
Commit a3d3aead authored by cortylal's avatar cortylal
Browse files

stats

parent fb301fb6
No related branches found
No related tags found
No related merge requests found
......@@ -170,14 +170,15 @@ class Stats
{
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT r.nom, count(*)
$requete_prepare = $bdd->db->prepare(" SELECT r.nom, count(*) AS count
FROM animal a, race r
WHERE a.race = r.id
GROUP BY r.nom, r.id
ORDER BY count DESC
LIMIT 10" ); // on prépare notre requête
$requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
$ligne = $requete_prepare->fetchAll(PDO::FETCH_ASSOC);
return $ligne;
}
......@@ -187,15 +188,16 @@ class Stats
$bdd = new Db();
$requete_prepare = $bdd->db->prepare(" SELECT e.nom, count(*)
$requete_prepare = $bdd->db->prepare(" SELECT e.nom, count(*) AS count
FROM animal a, race r, espece e
WHERE a.race = r.id
AND e.id = r.espece
GROUP BY e.nom, e.id
ORDER BY count DESC
LIMIT 10" ); // on prépare notre requête
$requete_prepare->execute();
$ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC);
$ligne = $requete_prepare->fetchAll(PDO::FETCH_ASSOC);
return $ligne;
}
......
......@@ -116,4 +116,40 @@
</tbody>
</table>
<br/>
<hr/>
<h4>Top 10 des espèces clientes</h4>
<table class="table">
<thead>
<th>Nom </th>
<th>Nombre d'individu </th>
</thead>
<tbody>
<?php foreach ($stats->top10Espece() as $ligne): ?>
<tr>
<td><?php echo $ligne["nom"]; ?> </td>
<td><?php echo $ligne["count"]; ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<br/>
<hr/>
<h4>Top 10 des races clientes</h4>
<table class="table">
<thead>
<th>Nom </th>
<th>Nombre d'individu' </th>
</thead>
<tbody>
<?php foreach ($stats->top10Race) as $ligne): ?>
<tr>
<td><?php echo $ligne["nom"]; ?> </td>
<td><?php echo $ligne["count"]; ?> </td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment