-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrech.php
35 lines (26 loc) · 967 Bytes
/
rech.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
<?php
try {
$bdd = new PDO('mysql:host=localhost;dbname=Otechnologie;charset=utf8', 'root', '');
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
?>
<?php
// Array with names
// get the q parameter from URL
$q = $_REQUEST["q"];
$hint = "";
if ($hint === "") {
$reponse = $bdd->query("SELECT * from produit where marque like '%$q%'");
$nb= $reponse->rowCount();
if($nb>0){
echo '<ul>';
while ($donnees = $reponse->fetch() ){
$hint.= ' <li><a href="single.php?id='.$donnees['id'].'"><img src="produit/'.$donnees['img'].'" style="width:50px">
'.$donnees['model'].' <i class="fa fa-angle-right"></i> '.$donnees['marque'].'</a></li>';
}
}
}
// Output "no suggestion" if no hint was found or output correct values
echo $hint;
?>