forked from parthshahk/Electronics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
113 lines (102 loc) · 4.09 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
include './includes/config.php';
include './includes/helpers.php';
$keywords='';
if(isset($_GET['q'])){
$keywords = filterStringBasic($_GET['q']);
}else{
header("Location: ".BaseAddress);
}
if($keywords == ''){
header('Location: '.BaseAddress);
}
$keywordsQuery = str_replace(" ","* *",$keywords);
$keywordsQuery = "*".$keywordsQuery."*";
$title = "Search for ".$keywords." - Malgadi Electronics";
$pageDescription = "Malgadi is a for the students, by the student's venture. It is a non-profitable organization started by the college students to provide better quality electronic components at a reasonable rate.";
$imagePath = BaseAddress."/images/logo.jpg";
$canonUrl = BaseAddress."/search.php";
$extendNavbar=0;
$searchVisibility=1;
$cartVisibility=1;
$subtitleVisibility=0;
include './includes/header.php';
?>
<script>
document.addEventListener('DOMContentLoaded', function(){
document.getElementById("search").value = "<?php echo $keywords; ?>";
});
</script>
<section class="grey-text text-darken-3">
<div class="container">
<div class="row">
<div class="col s12 center">
<h4 class="light" id="search-heading">
Search Results for '<?php echo $keywords; ?>'
</h4>
</div>
</div>
</div>
</section>
<?php
$cardObject = $pdo->prepare("SELECT * FROM items WHERE MATCH(Tags) AGAINST(:keywords IN BOOLEAN MODE) && `Category` != 'Kits' ORDER BY MATCH(Tags) AGAINST(:keywords IN BOOLEAN MODE) DESC");
$cardObject->execute(['keywords' => $keywordsQuery]);
include './includes/cards.php';
if($rows == null){
?>
<section class="grey-text text-darken-3">
<div class="container">
<div class="row">
<div class="col s12 center">
<h5 class="light">
No Direct Matches Found
</h5>
</div>
</div>
</div>
</section>
<script>
document.addEventListener('DOMContentLoaded', function(){
document.getElementById("search-heading").classList.add("hide");
});
</script>
<?php
}
?>
<section class="grey-text text-darken-3">
<div class="container">
<div class="row">
<div class="col s12 center">
<h4 class="light" id="kits-heading">
Related Kits
</h4>
</div>
</div>
</div>
</section>
<?php
$cardObject = $pdo->prepare("SELECT * FROM items WHERE MATCH(Tags, `Kit Contents`) AGAINST(:keywords IN BOOLEAN MODE) && `Category`='Kits' ORDER BY MATCH(Tags, `Kit Contents`) AGAINST(:keywords IN BOOLEAN MODE) DESC");
$cardObject->execute(['keywords' => $keywordsQuery]);
include './includes/cards.php';
if($rows == null){
?>
<script>
document.addEventListener('DOMContentLoaded', function(){
document.getElementById("kits-heading").classList.add("hide");
});
</script>
<?php
}
?>
<section class="grey-text text-darken-3 hide-on-large-only">
<div class="container">
<div class="row">
<div class="col s12 center">
<button class="btn-large waves-light waves-effect red" onclick="openSidenav()">Browse Categories<i class="fa fa-list right" aria-hidden="true"></i></button>
</div>
</div>
</div>
</section>
<?php
include './includes/footer.php';
?>