VOTE
'); $query = 'SELECT *, UNIX_TIMESTAMP(dateFin) as tf FROM liste_votations WHERE id=' . $db->protect($idVotation); $result = $db->query($query); $votation = $db->result->fetch_array(MYSQLI_ASSOC); if ($result === FALSE) { print "Votation non trouvée" . EOLH; }else { $now = date('Y-m-d'); if ( time() < $votation['tf'] ) { echo $votation["libelle"] . "
"; print ('');
$query='SELECT * FROM liste_votes WHERE idVotation="' .$db->protect( $idVotation) .'"';
$result = $db->query($query);
$votes = $db->result->fetch_all(MYSQLI_ASSOC);
foreach ($votes as $vote)
{
echo "
"; $query='SELECT * FROM liste_candidats WHERE idVotation=' . $idVotation . ' AND idVote=' . $vote["id"]; $result = $db->query($query); $candidats = $db->result->fetch_all(MYSQLI_ASSOC); echo "
"; } }else { print "Bonjour, vous pourrez consulter les résultats après la clôture du vote le " . formattedate('fr', $votation['tf'] , "Europe/Paris") . ""; } } print ('
" . $vote["libelle"] . "
"; $query='SELECT * FROM liste_candidats WHERE idVotation=' . $idVotation . ' AND idVote=' . $vote["id"]; $result = $db->query($query); $candidats = $db->result->fetch_all(MYSQLI_ASSOC); echo "
";
//$resultatCandidats = '';
foreach($candidats as $candidat)
{
$query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=' . $candidat["id"];
$result = $db->query($query);
$resultat = $db->result->fetch_array(MYSQLI_ASSOC);
echo $candidat["candidat"] . ' :' . $resultat["n"] . '
';
$resultatCandidats[$candidat['candidat']] = $resultat["n"];
}
array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC);
reset($resultatCandidats);
print("Remporte le vote : " . key($resultatCandidats));
unset($resultatCandidats);
print "
"; } }else { print "Bonjour, vous pourrez consulter les résultats après la clôture du vote le " . formattedate('fr', $votation['tf'] , "Europe/Paris") . ""; } } print ('