diff --git a/gestion/saisieVotes.php b/gestion/saisieVotes.php index 0f4e36b..b2282c4 100644 --- a/gestion/saisieVotes.php +++ b/gestion/saisieVotes.php @@ -7,21 +7,7 @@ require_once 'fonctions.inc.php'; $path = $_SERVER["PHP_SELF"]; $db = new db(); -function queryVotationName($db, $idVotation) :string -{ - $query = "SELECT libelle FROM liste_votations WHERE id='" . $idVotation . "'"; - $db->query($query); - $votationLine = $db->result->fetch_assoc(); - return $votationLine["libelle"]; -} -function queryVotes($db, $idVotation) -{ - $query = "SELECT * FROM liste_votes LEFT JOIN methods ON liste_votes.methode=methods.id WHERE idVotation='" . $idVotation . "'"; - $db->query($query); - $votes = $db->result->fetch_all(); - return $votes; -} $idVotation = getpost("id"); $method = getpost("method"); @@ -39,7 +25,7 @@ if (!empty($idVotation)) }else { $_SESSION["idVotation"] = $idVotation; - $votationName = queryVotationName($db, $idVotation); + $votationName = $db->queryVotationName($db, $idVotation); } }else { @@ -48,7 +34,7 @@ if (!empty($idVotation)) if (!empty($_SESSION["idVotation"])) { $idVotation = $_SESSION["idVotation"]; - $votationName = queryVotationName($db, $idVotation); + $votationName = $db->queryVotationName($db, $idVotation); } } } @@ -61,11 +47,11 @@ print('

print('
'); -$votes = queryVotes($db, $idVotation); +$votes = $db->queryVotes($db, $idVotation); if (!empty($votes)) { print(""); + print("vote"); foreach ($votes as $value) { print ("" . EOL); diff --git a/include/db.class.php b/include/db.class.php index e9f656c..41ab75e 100644 --- a/include/db.class.php +++ b/include/db.class.php @@ -112,5 +112,21 @@ class dbcore $query='SELECT idVotant, COUNT(value) as resultat FROM lalis_vote WHERE value="' . $value . '" AND idVote="' . $i . '" '; } } + + function queryVotationName($db, $idVotation) :string + { + $query = "SELECT libelle FROM liste_votations WHERE id='" . $idVotation . "'"; + $db->query($query); + $votationLine = $db->result->fetch_assoc(); + return $votationLine["libelle"]; + } + + function queryVotes($db, $idVotation) + { + $query = "SELECT * FROM liste_votes LEFT JOIN methods ON liste_votes.methode=methods.id WHERE idVotation='" . $idVotation . "'"; + $db->query($query); + $votes = $db->result->fetch_all(); + return $votes; + } } ?>
"); - print("voteméthode
méthode
" . $value[1] . "" . $value[5] . "