-
Notifications
You must be signed in to change notification settings - Fork 0
/
livesearch.php
92 lines (80 loc) · 2.43 KB
/
livesearch.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
// Array with names
$a[] = "Mushroom Pepper Fry";
$a[] = "salads";
$a[] = "soups";
$a[] = "seafood";
$a[] = "fingerfood";
$a[] = "canpes";
$a[] = "fish";
$a[] = "savouybaking";
$a[] = "dip";
$a[] = "meat";
$a[] = "Red Lentil Dumplings";
$a[] = "Caramelized Fennel on Herbed Polenta";
$a[] = "Lazy Day Peanut Noodle Salad";
$a[] = "Weekday Vegetable Soup";
$a[] = "Green Curry Dumplings";
$a[] = "Kale Quinoa Bites";
$a[] = "Pomelo Noodles";
$a[] = "Rye Pasta";
$a[] = "Coconut Quinoa Bowl";
$a[] = "Momo Dumplings";
$a[] = "Lentils with Wine-Glazed Vegetable";
$a[] = "Mung Yoga Bowl";
$a[] = "Giant Lemon Fennel Beans";
$a[] = "Green Curry Porridge";
$a[] = "Immunity Soup";
$a[] = "Stuffed Cinnamon Donuts";
$a[] = "Ginger-Peach Shortbread Cobbler";
$a[] = "Buttermilk-Glazed Cherry Sheet Cake";
$a[] = "Orange-and-Basil Macerated Cherries";
$a[] = "Buttermilk-Plum Ice Cream";
$a[] = "Mixed Stone-Fruit Pie";
$a[] = "Fresh Apple Cake";
$a[] = "Free-Form Strawberry Cheesecake";
$a[] = "Nutter Butter®-Banana Pudding Trifle";
$a[] = "Double Apple Pie with Cornmeal Crust";
$a[] = "Mocha Java Cakes";
$a[] = "Blackberry-Apple Upside-Down Cake";
$a[] = "Luscious Lemon Bars";
$a[] = "Praline Pull-Apart Bread";
$a[] = "Strawberry-Buttermilk Sherbet";
$a[] = "So Good Brownies";
$a[] = "Buttermilk Breakfast Cake ";
$a[] = "Peach-and-Toasted Pecan Ice Cream";
$a[] = "Rustic Plum Tart";
$a[] = "Chocolate Marble Sheet Cake";
$a[] = "Caramelized Banana Pudding ";
$a[] = "Apple Stack Cake";
$a[] = "Coca Cola";
$a[] = "Coca Cola Light ";
$a[] = "Fanta";
$a[] = "Sprite";
$a[] = "Nestea Lemon";
$a[] = "Nestea Peach";
$a[] = "Cappy Apple";
$a[] = "Cappy Orange";
$a[] = "Cappy Lemon";
$a[] = "Cappy Grape";
$a[] = "Cappy Cherry";
// get the q parameter from URL
$q = $_GET["q"];
$hint = "";
// lookup all hints from array if $q is different from ""
if ($q !== "") {
$q = strtolower($q);
$len=strlen($q);
foreach($a as $name) {
if (stristr($q, substr($name, 0, $len))) {
if ($hint === "") {
$hint = "<a href='#' onclick='addToCartFromSearch(this);'> $name </a>";
} else {
$hint .= "<br> <a href='#' onclick='addToCartFromSearch(this);'> $name </a>";
}
}
}
}
// Output "no suggestion" if no hint was found or output correct values
echo $hint === "" ? "no suggestion" : $hint;
?>