VOTE
'); $query = 'SELECT *, UNIX_TIMESTAMP(DATE_ADD(dateFin, INTERVAL 1 DAY)) 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"] . "
"; $listeAdherents = listeAdherents(); 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 = ''; $query='SELECT COUNT(*) as n FROM votes WHERE idVotation=' . $db->protect($idVotation) . ' AND idVote=' . $vote["id"] .' AND idCandidat=0'; $result = $db->query($query); $resultat = $db->result->fetch_array(MYSQLI_ASSOC); $blanc = $resultat["n"]; echo 'Votes blancs : ' . $blanc . '
'; 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"]; $total += $resultat["n"]; } array_multisort($resultatCandidats, SORT_DESC, SORT_NUMERIC); reset($resultatCandidats); if ($total >= $blanc) { print("Remporte le vote : " . key($resultatCandidats)); unset($resultatCandidats); print("
"); }else { print("Aucun candidat n'emporte le vote, car il y a plus de 50% de votes blancs.
"); } listeVotants($idVotation, $vote["id"], $listeAdherents); print("
" . EOLH); } }else { print "Bonjour, vous pourrez consulter les résultats à partir du " . formattedate('fr', $votation['tf'] , "Europe/Paris") . ""; } } print ('