-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
40 lines (31 loc) · 1.07 KB
/
search.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
<?php
require_once "./classes/DBAccess.php";
include "./settings/db.php";
$title = "Product Search";
$pageHeading = "Products";
//start buffer
ob_start();
//display the search form
//include "templates/searchForm.html.php";
//check if the search button has been pressed
if (isset($_GET["submitButton"]) && isset($_GET["search"])) {
$search = $_GET["search"];
//create database object
$db = new DBAccess($dsn, $username, $password);
//connect to database
$pdo = $db->connect();
//set up query to execute
$sql = "select photo, price, salePrice, itemName, itemId FROM `item` where itemName like :itemName";
//= :productName"
$stmt = $pdo->prepare($sql);
//$stmt->bindValue(":itemName", "%$search%");//"$search
$stmt->bindValue(":itemName", "%$search%");
//execute SQL query
$rows = $db->executeSQL($stmt);
//display products
include "./templates/products.html.php";
}
$output_products = ob_get_clean();
require_once "./displayCategory.php";
require_once "./displayCategory-footer.php";
include "./templates/layout.html.php";