forked from chriszhou1992/ABCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
43 lines (35 loc) · 1.82 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
<?php
$search = $_POST['search'];
require_once 'classes/Query.php';
$query = new Query();
$result = $query->queryDatabase($search);
if(count($result) === 0):
echo "<div class='alert alert-black alert-dismissable'>
<button type='button' class='close customClose' data-dismiss='alert' aria-hidden='true'><i class='fa fa-times'></i></button>
<i class='fa fa-exclamation-triangle customWarning'></i>  
Sorry, there is no game or company whose name contains <strong class='customStrong'>' $search '</strong> found.
</div>";
return;
endif;
echo "<div class='alert alert-black alert-dismissable'>
<button type='button' class='close customClose' data-dismiss='alert' aria-hidden='true'><i class='fa fa-times'></i></button>
<i class='fa fa-info-circle customInfo'></i>   ";
if(count($result) === 1) {
echo "There is  <strong class='customStrong'>".count($result)."</strong>  game or company whose name contains <strong class='customStrong'>' $search '</strong> found.";
} else {
echo "There are  <strong class='customStrong'>".count($result)."</strong>  games / companies whose names contain <strong class='customStrong'> ' $search '</strong> found.";
}
echo "</div><div class='dismissableHR'><br></div>";
foreach($result as $record):
$imageSrc = $record['imageURL'];
echo "<img src='$imageSrc' alt='Loading...' style='width: 50px; 'height: 70px;>  ";
$name = $record['name'];
$send = str_replace("'", "!-!-!", $name);
if(isset($record['headquarter'])) {
echo "<span class='companies' name='$send'>$name</span><hr>";
} else {
echo "<span class='games' name='$send'>$name</span><hr>";
}
$brief = $record['brief'];
echo "$brief<hr>";
endforeach;