1
0

optimisation

This commit is contained in:
Daniel Tartavel 2022-09-25 18:11:42 +02:00
parent bb7d54afc8
commit 461cd822c3
2 changed files with 20 additions and 18 deletions

View File

@ -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('<br><br>
print(' <div class="row">
<div class="col-lg-12 text-center">');
$votes = queryVotes($db, $idVotation);
$votes = $db->queryVotes($db, $idVotation);
if (!empty($votes))
{
print("<table><tr><td>");
print("vote</td><td>méthode</td></tr>");
print("<b>vote</b></td><td><b>méthode</b></td></tr>");
foreach ($votes as $value)
{
print ("<tr><td>" . $value[1] . "</td><td>" . $value[5] . "</td></tr>" . EOL);

View File

@ -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;
}
}
?>