optimisation
This commit is contained in:
parent
bb7d54afc8
commit
461cd822c3
@ -7,21 +7,7 @@ require_once 'fonctions.inc.php';
|
|||||||
$path = $_SERVER["PHP_SELF"];
|
$path = $_SERVER["PHP_SELF"];
|
||||||
$db = new db();
|
$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");
|
$idVotation = getpost("id");
|
||||||
$method = getpost("method");
|
$method = getpost("method");
|
||||||
@ -39,7 +25,7 @@ if (!empty($idVotation))
|
|||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$_SESSION["idVotation"] = $idVotation;
|
$_SESSION["idVotation"] = $idVotation;
|
||||||
$votationName = queryVotationName($db, $idVotation);
|
$votationName = $db->queryVotationName($db, $idVotation);
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
@ -48,7 +34,7 @@ if (!empty($idVotation))
|
|||||||
if (!empty($_SESSION["idVotation"]))
|
if (!empty($_SESSION["idVotation"]))
|
||||||
{
|
{
|
||||||
$idVotation = $_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">
|
print(' <div class="row">
|
||||||
<div class="col-lg-12 text-center">');
|
<div class="col-lg-12 text-center">');
|
||||||
|
|
||||||
$votes = queryVotes($db, $idVotation);
|
$votes = $db->queryVotes($db, $idVotation);
|
||||||
if (!empty($votes))
|
if (!empty($votes))
|
||||||
{
|
{
|
||||||
print("<table><tr><td>");
|
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)
|
foreach ($votes as $value)
|
||||||
{
|
{
|
||||||
print ("<tr><td>" . $value[1] . "</td><td>" . $value[5] . "</td></tr>" . EOL);
|
print ("<tr><td>" . $value[1] . "</td><td>" . $value[5] . "</td></tr>" . EOL);
|
||||||
|
@ -112,5 +112,21 @@ class dbcore
|
|||||||
$query='SELECT idVotant, COUNT(value) as resultat FROM lalis_vote WHERE value="' . $value . '" AND idVote="' . $i . '" ';
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user