par
yoann38 » 02 nov. 2019, 17:34
En reprenant ton exemple:
<?php
$note = array(0,1,2,3,4,5);
for($i=0; $i<=5; $i++){
$note[$i];
$valeur = array('A éviter', 'Pas terrible', 'C\'est pas mal', 'Sympa', 'Bien', 'Excellent');
for($i=0; $i<=5; $i++){
$valeur[$i];
$note_avis = $bdd->prepare('SELECT COUNT(*) as nb_votes FROM avis WHERE note = ? AND id_bar= '.$bar_id);
$note_avis->execute(array( $note[$i]));
while($dos=$note_avis->fetch()){
$nb_votes= $dos['nb_votes'];
$pourcentage_vote = $nb_votes * 100 / $avis_note['nb_vote'];
echo '<div class="row">
<div class="col-lg-10 col-9">
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: '.$pourcentage_vote.'%" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="col-lg-2 col-3"><small><strong>'.$valeur[$i].' ('.$nb_votes.')</strong></small></div>
</div>';
//echo $nb_votes . ' votes pour la note ' . $note[$i] . ' ' . $valeur[$i] . '<br /> ' ;
}
}
}
?>
Par contre exist'il une fonction pour affiché à l'inverse.
C'est dire commencer par Excellent, Bien, ... plutot que l'inverse
Je préfere affiché les bonnes notes avant
En reprenant ton exemple:
[PHP]
<?php
$note = array(0,1,2,3,4,5);
for($i=0; $i<=5; $i++){
$note[$i];
$valeur = array('A éviter', 'Pas terrible', 'C\'est pas mal', 'Sympa', 'Bien', 'Excellent');
for($i=0; $i<=5; $i++){
$valeur[$i];
$note_avis = $bdd->prepare('SELECT COUNT(*) as nb_votes FROM avis WHERE note = ? AND id_bar= '.$bar_id);
$note_avis->execute(array( $note[$i]));
while($dos=$note_avis->fetch()){
$nb_votes= $dos['nb_votes'];
$pourcentage_vote = $nb_votes * 100 / $avis_note['nb_vote'];
echo '<div class="row">
<div class="col-lg-10 col-9">
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: '.$pourcentage_vote.'%" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
<div class="col-lg-2 col-3"><small><strong>'.$valeur[$i].' ('.$nb_votes.')</strong></small></div>
</div>';
//echo $nb_votes . ' votes pour la note ' . $note[$i] . ' ' . $valeur[$i] . '<br /> ' ;
}
}
}
?>
[/PHP]
Par contre exist'il une fonction pour affiché à l'inverse.
C'est dire commencer par Excellent, Bien, ... plutot que l'inverse
Je préfere affiché les bonnes notes avant