-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresultspage.php
170 lines (156 loc) · 6.24 KB
/
resultspage.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GameInc</title>
<!-- CSS only -->
<style>
nav {
background: #1b2838;
}
thead {
background: #1b2838;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
<script src="https://kit.fontawesome.com/c3c1353c4c.js" crossorigin="anonymous"></script>
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>
</head>
<body>
<!-- Connector untuk menghubungkan PHP dan SPARQL -->
<?php
require_once("sparqllib.php");
$searchInput = "";
if (isset($_POST['search'])) {
$searchInput = $_POST['search'];
$data = sparql_get(
"http://localhost:3030/gaminc",
"
PREFIX id: <https://gameinc.com/>
PREFIX item: <https://gameinc.com/ns/item#>
SELECT *
WHERE {
?id item:Title ?Title ;
item:Developer ?Developer ;
item:Publisher ?Publisher ;
item:Year ?Year;
item:Genre ?Genre ;
item:Platform ?Platform;
item:Harga ?Harga .
FILTER
(regex (?Title, '$searchInput', 'i')
|| regex (?Developer, '$searchInput', 'i')
|| regex (?Publisher, '$searchInput', 'i')
|| regex (?Year, '$searchInput', 'i')
|| regex (?Genre, '$searchInput', 'i')
|| regex (?Platform, '$searchInput', 'i')
|| regex (?Harga, '$searchInput', 'i'))
}
"
);
} else {
$data = sparql_get(
"http://localhost:3030/gaminc",
"
PREFIX id: <https://gameinc.com/>
PREFIX item: <https://gameinc.com/ns/item#>
SELECT *
WHERE {
?id item:Title ?Title ;
item:Developer ?Developer ;
item:Publisher ?Publisher ;
item:Year ?Year;
item:Genre ?Genre ;
item:Platform ?Platform;
item:Harga ?Harga .
}
"
);
}
if (!isset($data)) {
print "<p>Error: " . sparql_errno() . ": " . sparql_error() . "</p>";
}
?>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg sticky-top">
<div class="container container-fluid">
<a class="navbar-brand" href="index.php"><img src="https://i.ibb.co/3NJnhWk/Game-Inc-logo-removebg-preview-small.png" style="width:180px" alt="Logo"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse">
<ul class="navbar-nav me-auto mb-2 mb-lg-0 h5">
</ul>
<form class="d-flex" role="search" action="" method="post" id="search" name="search">
<input class="form-control me-2" type="search" placeholder="Search for games" aria-label="Search" name="search">
<button class="btn btn-secondary" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<!-- Body -->
<div class="container container-fluid my-3 mb-5">
<?php
if ($searchInput != NULL) {
?>
<i class="fa-solid fa-magnifying-glass"></i><span> Showing results for <b>"<?php echo $searchInput; ?>"</b></span>
<?php
}
?>
<table class="table table-bordered table-hover text-center table-responsive sortable">
<thead class="text-white align-middle">
<tr>
<th>Title</th>
<th>Developer</th>
<th>Publisher</th>
<th>Year</th>
<th>Genre</th>
<th>Platform</th>
<th>Price ($)</th>
</tr>
</thead>
<tbody class="align-middle">
<?php foreach ($data as $data) : ?>
<td><?= $data['Title'] ?></td>
<td><?= $data['Developer'] ?></td>
<td><?= $data['Publisher'] ?></td>
<td><?= $data['Year'] ?></td>
<td><?= $data['Genre'] ?></td>
<td><?= $data['Platform'] ?></td>
<td><?= $data['Harga'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php
if ($searchInput != NULL) {
?>
<a href="resultspage.php">
<button type="button" class="btn btn-danger float-end">Reset</button>
</a>
<?php
}
?>
</div>
<!-- Footer -->
<?php
if ($searchInput != NULL) {
?>
<footer class="footer text-light text-center bg-dark pb-1 fixed-bottom">
<p>Copyright - Anki Prawira Hidayat</p>
</footer>
<?php
} else {
?>
<footer class="footer text-light text-center bg-dark pb-1">
<p>Copyright - Anki Prawira Hidayat</p>
</footer>
<?php
}
?>
</body>
</html>