<?php
include("../config.php3");
include($BIB."bib_generic.php3");


for($r=1;$r<21;$r++)
{
	# nombre de réponses pour la question
	$reponses = main_db_query("SELECT DISTINCT(Reponse) FROM Questionnaire WHERE Question='v".$r."'");
	$nb_reponses = db_num_rows($reponses);
	
	echo "v".$r." (".$nb_reponses." choix) -- ";
	
	# on check chaque réponse
	while($reponse = db_fetch_array($reponses))
	{
//	echo "SELECT COUNT(Reponse) AS total FROM Questionnaire WHERE Question='v".$r."' AND Reponse='".$reponse['Reponse']."'";
		$rep = db_fetch_array(main_db_query("SELECT COUNT(Reponse) AS total FROM Questionnaire WHERE Question='v".$r."' AND Reponse='".$reponse['Reponse']."'"));
		$tab[$r][$reponse['Reponse']] = $rep[total];
		$tab[$r]["total"] += $rep[total];
		echo $reponse['Reponse'].":";
		echo $tab[$r][$reponse['Reponse']]." * ";
	}
	
	echo "<br>";
	echo "v".$r." -- ";
	
	db_data_seek($reponses,0);
	
	# deuxieme passe pour faire les pourcentages
	while($reponse = db_fetch_array($reponses))
	{
		$tab[$r][$reponse['Reponse']."p"] = $tab[$r][$reponse['Reponse']]/$tab[$r]["total"]*100;
		$x = round($tab[$r][$reponse['Reponse']."p"]);
		echo $reponse['Reponse'].":";
		echo $x."% * ";
	}
	
	echo "<br>";
}

$rows=main_db_query("SELECT * FROM Questionnaire WHERE Question='v21' and Reponse!='0'");
$r=0;
while($row = db_fetch_array($rows))
{
	echo "<hr><b>".++$r."</b><br>";
	echo $row['Reponse'];
}

?>