Bonjour,
Je n'arrive pas à incrémenter un nombre dans une boule for.
Voici ce que j'aimerais arriver à faire:
J'ai un sondage ex:
1 -> 50% (2 vote)
2 -> 0% (0 vote)
2 -> 0% (0 vote)
3 -> 0% (0 vote)
4 -> 0% (0 vote)
5 -> 50% (2 vote)
1,2,3, etc étant la note atribuée
J'aimerais trouver le total de pourcentage en fonction du nombres de votes ex:
1 -> 50% (2 vote) -----> 100% ( 2vote * 50%)
2 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
2 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
3 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
4 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
5 -> 50% (2 vote) -----> 100% ( 2vote * 50%)
Et j'aimerais donc afficher au total 200%.
Voici le code:
Merci pour votre aide.
Clément
Modifié par clement101 (06 Aug 2006 - 14:40)
Je n'arrive pas à incrémenter un nombre dans une boule for.
Voici ce que j'aimerais arriver à faire:
J'ai un sondage ex:
1 -> 50% (2 vote)
2 -> 0% (0 vote)
2 -> 0% (0 vote)
3 -> 0% (0 vote)
4 -> 0% (0 vote)
5 -> 50% (2 vote)
1,2,3, etc étant la note atribuée
J'aimerais trouver le total de pourcentage en fonction du nombres de votes ex:
1 -> 50% (2 vote) -----> 100% ( 2vote * 50%)
2 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
2 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
3 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
4 -> 0% (0 vote) -----> 0% ( 2vote * 0%)
5 -> 50% (2 vote) -----> 100% ( 2vote * 50%)
Et j'aimerais donc afficher au total 200%.
Voici le code:
for($i = 0; $i < $vote_options; $i++)
{
$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
$essai2= $vote_percent * $vote_info[$i]['vote_result'];//essai2 calcul pour une seule note ex: 100%
$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
if ( count($orig_word) )
{
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
$template->assign_block_vars("poll_option2", array(
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
'ESSAI2' => $essai2,
'POLL_OPTION_IMG' => $vote_graphic_img,
'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
);
}
J'aimerais incrémenter avec la boucle for l' $essai2
Merci pour votre aide.

Clément
Modifié par clement101 (06 Aug 2006 - 14:40)