Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <?php
- include 'functions.php';
- session_start();
- if(isset($_GET['ranking'])){
- if(isset($_GET['ID_PRO'])){
- try {
- $bdd = new PDO("mysql:host=localhost;dbname=vignerons", "root", "");
- $bdd->query("SET NAMES 'utf8'");
- $idProduit = $_GET['ID_PRO'];
- $emailUser = $_SESSION['user'];
- $reponseClient = $bdd->query("SELECT * FROM utilisateur WHERE UTI_EMAIL = '$emailUser'");
- $donneesClient = $reponseClient->fetch();
- $idUser = $donneesClient['ID_UTI'];
- $ranking = $_GET['ranking'];
- $reponsefeed = $bdd->query("SELECT * FROM feedback WHERE ID_PRO_FEE= $idProduit AND ID_UTI_FEE = $idUser");
- $nombrefeed = $reponsefeed->rowCount();
- if ($nombrefeed == 0) {
- $bdd->query("INSERT INTO feedback(ID_PRO_FEE, ID_UTI_FEE, FEE_NOTE) VALUES($idProduit, $idUser, $ranking)");
- }
- else {
- $bdd->query("UPDATE feedback SET FEE_NOTE = $ranking WHERE ID_PRO_FEE = $idProduit AND ID_UTI_FEE = $idUser");
- }
- } catch (\Exception $e) {
- }
- }
- }
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- <link rel="stylesheet" href="cs.css">
- <title>Index html</title>
- </head>
- <body>
- <header>
- </header >
- <section>
- <table id="tableauAumillieu">
- <tr>
- <td id="titre1">V I G N E R O N S</td>
- </tr>
- <tr>
- <td id="titre">- 1975 -</td>
- </tr>
- </table>
- <table id="deuxiemeTableau">
- <tr>
- <td><a href="acceuil.php" target="_self">ACCEUIL</a></td>
- <td><a href="nosProduits.php">NOS PRODUITS</a></td>
- <td><a href="nosPointsDeVente.php">POINTS DE VENTE</a></td>
- <td><a href="contact.php">CONTACT</a></td>
- <td>
- <?php
- if (isset($_SESSION['user']) AND ($_SESSION['user'] != null)) {
- ?>
- <a href="logout.php"><?php echo "Not " . $_SESSION['user'] . " ?";?></a>
- <?php
- }
- else {
- ?>
- <a href="Connexion.php">CONNEXION</a>
- <?php
- }
- ?>
- </td>
- </tr>
- </table>
- <hr class="hr">
- <?php
- try {
- $bdd = new PDO("mysql:host=localhost;dbname=vignerons", "root", "");
- $bdd->query("SET NAMES 'utf8'");
- $reponse = $bdd->query("SELECT * FROM produit");
- $reponse->setFetchMode(PDO::FETCH_BOTH);
- while ( $donnees = $reponse->fetch() ){
- $connecte = true;
- if (isset($_SESSION['user']) AND ($_SESSION['user'] != null)) {
- $emailUser = $_SESSION['user'];
- $idProduit = $donnees['ID_PRO'];
- $reponseClient = $bdd->query("SELECT * FROM utilisateur WHERE UTI_EMAIL = '$emailUser'");
- $donneesClient = $reponseClient->fetch();
- $idUser = $donneesClient['ID_UTI'];
- if (isset($_GET['FEE_NOTE'])) {
- $ranking = $_GET['FEE_NOTE'];
- $reponsefeed = $bdd->query("SELECT * FROM feedback WHERE ID_PRO_FEE= $idProduit AND ID_UTI_FEE = $idUser");
- $nombrefeed = $reponsefeed->rowCount();
- if ($nombrefeed == 0) {
- $bdd->query("INSERT INTO feedback(ID_PRO_FEE, ID_UTI_FEE, FEE_NOTE) VALUES($idProduit, $idUser, $ranking)");
- }
- else {
- $bdd->query("UPDATE feedback SET FEE_NOTE = $ranking WHERE ID_PRO_FEE = $idProduit AND ID_UTI_FEE = $idUser");
- }
- }
- else {
- $reponsefeed = $bdd->query("SELECT * FROM feedback WHERE ID_PRO_FEE = $idProduit AND ID_UTI_FEE = $idUser");
- $nombrefeed = $reponsefeed->rowCount();
- if ($nombrefeed != 0) {
- $donneesback = $reponsefeed->fetch();
- $ranking = $donneesback['FEE_NOTE'];
- }
- else {
- $ranking = 99;
- }
- }
- }
- else {
- $connecte = false;
- }
- ?>
- <table>
- <tr>
- <td><div class='cartouche'>
- <div class='card'>
- <br><br>
- <div class='pict'>
- <img class="imfinal" src="./<?= $donnees['PRO_LIENPHOTOS']?>" ><br><br><br>
- </div>
- </div>
- </div>
- </td>
- <td>
- <div class='titreVinDeconnecte'>
- <?php echo $donnees['PRO_NOM']; ?></td>
- </div>
- <td>
- <div class="symbole">
- <?php
- if ($connecte == true) {
- ?>
- <p class="titreVinFinal"> <?php
- echo $donnees['PRO_NOM'];
- ?></p>
- <?php
- if ($ranking == 99) {
- ?>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit ; ?>&ranking=1"><img src="./Photos/sad-face-outline-unselected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-unselected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-unselected.png" class="icons"/></a>
- <?php
- }
- elseif ($ranking == 1) {
- ?>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=1"><img src="./Photos/sad-face-outline-selected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-unselected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-unselected.png" class="icons"/></a>
- <?php
- }
- elseif ($ranking == 2) {
- ?>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=1"><img src="./Photos/sad-face-outline-unselected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-selected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-unselected.png" class="icons"/></a>
- <?php
- }
- elseif ($ranking == 3) {
- ?>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=1"><img src="./Photos/sad-face-outline-unselected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=2"><img src="./Photos/silent-emoticon-face-with-missed-mouth-symbol-of-stroke-unselected.png" class="icons"/></a>
- <a href="nosProduits.php?ID_PRO=<?php echo $idProduit; ?>&ranking=3"><img src="./Photos/smiling-emoticon-face-selected.png" class="icons"/></a>
- <?php
- }
- ?>
- <?php
- }
- ?>
- </div>
- </td>
- </tr>
- </table>
- <br>
- <?php
- }
- $bdd = NULL;
- }
- catch (PDOException $e) {
- echo "Erreur !: " . $e->getMessage() . "<br />";
- die();
- }
- ?>
- </section>
- <footer>
- </footer>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement