From d180061bf813ccbac6089f0f19e2e90b9671b5b2 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 23 Jun 2018 15:36:37 -0600 Subject: [PATCH] Add online store search ( issue #8 ) --- public/index.php | 3 +++ public/parts/nav.php | 9 ++++++-- public/parts/search.php | 46 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 public/parts/search.php diff --git a/public/index.php b/public/index.php index 174005f..1401259 100644 --- a/public/index.php +++ b/public/index.php @@ -32,6 +32,9 @@ if (isset($_GET['page'])) { $page = "404"; } break; + case "search": + $page = "search"; + break; case "item": if (isset($_GET['id']) && $binstack->has('items', ['itemid' => $_GET['id']])) { $page = "item"; diff --git a/public/parts/nav.php b/public/parts/nav.php index 7b6c08e..a4311a6 100644 --- a/public/parts/nav.php +++ b/public/parts/nav.php @@ -36,9 +36,14 @@ foreach ($cats as $c) { -
+
- + +
diff --git a/public/parts/search.php b/public/parts/search.php new file mode 100644 index 0000000..0dd1029 --- /dev/null +++ b/public/parts/search.php @@ -0,0 +1,46 @@ +select('items', 'itemid', [ + 'AND' => [ + 'price[>]' => 0, + 'OR' => [ + 'name[~]' => $query, + 'code1' => $query, + 'code2' => $query, + 'text1[~]' => $query + ] + ], 'LIMIT' => 20]); + +$items = []; + +foreach ($dbitems as $i) { + $items[] = new Item($i); +} +?> +
+

Search

+ +
+ 0) { + foreach ($items as $i) { + echo RenderItem::line($i); + } + } else { + ?> +

No results found for .

+ +
+
\ No newline at end of file