-
Notifications
You must be signed in to change notification settings - Fork 0
/
getSearchResults.php
executable file
·42 lines (38 loc) · 1.6 KB
/
getSearchResults.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
//Page pour l'information de base des Items pour quand l'utilisateur est dans une categorie
require_once("./admin/code/4006_fns.php");
$bdd = cnx_bdd('eam6014', 'bddparm');
//Items appartenant a le resultat de la recherche
$fetchAllItems = $bdd->prepare('SELECT Item.idItem, Item.Nom, Item.Image, Item.Prix, Item.DateMaj, Item.Actif, scoreTotal.Score
FROM Item LEFT JOIN (SELECT idItem, AVG( score ) AS score FROM Appreciation GROUP BY idItem) as scoreTotal
ON Item.idItem=scoreTotal.idItem WHERE Item.nom LIKE :search OR Item.description LIKE :search');
$fetchAllItems->execute(array(':search' => '%'.$_GET['query'].'%'));
if($fetchAllItems->rowCount() != 0)
{
echo "<table>";
while($fetchAllItemsData = $fetchAllItems->fetch())
{
if($fetchAllItemsData['Actif'] == 1)
{
//On crée une liste des Items d'apres la querry
echo "<tr><td><img src=\"images/" . $fetchAllItemsData['Image'] . "\" width=\"300\" height=\"300\"></td>
<td>" . $fetchAllItemsData['Nom'] . "</br>Prix: ".
sprintf("%01.2f", $fetchAllItemsData['Prix']) . "$</br>
Appreciation: ";
if($fetchAllItemsData['Score'] == NULL )
echo " -</br>";
else
{
echo sprintf("%01.1f", $fetchAllItemsData['Score']) . "/5</br>";
}
echo "Date modifié: " . $fetchAllItemsData['DateMaj'] . "</br>
<input type=\"button\" onclick=\"getItemData(".$fetchAllItemsData['idItem'].")\" value=\"Voir les détails \"></td></tr>
<tr><td colspan=\"2\"><hr></td></tr>";
}
}
$fetchAllItems->closeCursor();
echo "</table>";
}
else
echo "Aucun Item trouver!";
?>