forked from chriszhou1992/ABCD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchOptions.php
160 lines (139 loc) · 6.31 KB
/
searchOptions.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
<?php
require_once "classes/connecToDB.php";
$con = connectToDB();
if($con === false):
return;
endif;
if(isset($_POST['option1'])):
$sql = "SELECT g.*, c.num_likes
FROM games g
INNER JOIN companies c
ON g.publishers=c.name
having c.num_likes = (
select MAX(num_likes) from companies)";
$result = mysqli_query($con, $sql);
if(!$result) {
die('Error: ' . mysqli_error($con));
}
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($result->num_rows === 1) {
echo "There is  <strong class='customStrong'>".$result->num_rows."</strong>  game found in the database whose publisher accumulates the most Likes.";
} else {
echo "There are  <strong class='customStrong'>".$result->num_rows."</strong>  games found in the database whose publishers accumulate the most Likes.";
}
echo "</div><div class='dismissableHR'><br></div>";
while($row = mysqli_fetch_array($result)) {
$imageSrc = $row['imageURL'];
echo "<img src='$imageSrc' alt='Loading...' style='width: 50px; 'height: 70px;>  ";
$name = $row['name'];
$send = str_replace("'", "!-!-!", $name);
if(isset($row['headquarter'])) {
echo "<span class='companies' name='$send'>$name</span><hr>";
} else {
echo "<span class='games' name='$send'>$name</span><hr>";
}
$brief = $row['brief'];
echo "$brief<hr>";
}
endif;
if(isset($_POST['option2'])):
$sql = "SELECT *
From games
where num_likes = (
select MAX(num_likes) from games)";
$result = mysqli_query($con, $sql);
if(!$result) {
die('Error: ' . mysqli_error($con));
}
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($result->num_rows === 1) {
echo "There is  <strong class='customStrong'>".$result->num_rows."</strong>  game found in the database with the most Likes.";
} else {
echo "There are  <strong class='customStrong'>".$result->num_rows."</strong>  games found in the database withe the most Likes.";
}
echo "</div><div class='dismissableHR'><br></div>";
while($row = mysqli_fetch_array($result)) {
$imageSrc = $row['imageURL'];
echo "<img src='$imageSrc' alt='Loading...' style='width: 50px; 'height: 70px;>  ";
$name = $row['name'];
$send = str_replace("'", "!-!-!", $name);
if(isset($row['headquarter'])) {
echo "<span class='companies' name='$send'>$name</span><hr>";
} else {
echo "<span class='games' name='$send'>$name</span><hr>";
}
$brief = $row['brief'];
echo "$brief<hr>";
}
endif;
if(isset($_POST['option3'])):
$sql = "SELECT DISTINCT c.*, g.num_likes
FROM companies c
INNER JOIN games g
ON c.name=g.publishers
having g.num_likes = (
select MAX(num_likes) from games)";
ini_set('max_execution_time', 300000);
$result = mysqli_query($con, $sql);
if(!$result) {
die('Error: ' . mysqli_error($con));
}
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($result->num_rows === 1) {
echo "There is  <strong class='customStrong'>".$result->num_rows."</strong>  publisher found in the database which publishes games with the most Likes.";
} else {
echo "There are  <strong class='customStrong'>".$result->num_rows."</strong>  publishers found in the database which publish games with the most Likes.";
}
echo "</div><div class='dismissableHR'><br></div>";
while($row = mysqli_fetch_array($result)) {
$imageSrc = $row['imageURL'];
echo "<img src='$imageSrc' alt='Loading...' style='width: 50px; 'height: 70px;>  ";
$name = $row['name'];
$send = str_replace("'", "!-!-!", $name);
if(isset($row['headquarter'])) {
echo "<span class='companies' name='$send'>$name</span><hr>";
} else {
echo "<span class='games' name='$send'>$name</span><hr>";
}
$brief = $row['brief'];
echo "$brief<hr>";
}
endif;
if(isset($_POST['option4'])):
$sql = "SELECT *
From companies
where num_likes = (
select MAX(num_likes) from companies)";
$result = mysqli_query($con, $sql);
if(!$result) {
die('Error: ' . mysqli_error($con));
}
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($result->num_rows === 1) {
echo "There is  <strong class='customStrong'>".$result->num_rows."</strong>  publisher found in the database with the most Likes.";
} else {
echo "There are  <strong class='customStrong'>".$result->num_rows."</strong>  publishers found in the database with the most Likes.";
}
echo "</div><div class='dismissableHR'><br></div>";
while($row = mysqli_fetch_array($result)) {
$imageSrc = $row['imageURL'];
echo "<img src='$imageSrc' alt='Loading...' style='width: 50px; 'height: 70px;>  ";
$name = $row['name'];
$send = str_replace("'", "!-!-!", $name);
if(isset($row['headquarter'])) {
echo "<span class='companies' name='$send'>$name</span><hr>";
} else {
echo "<span class='games' name='$send'>$name</span><hr>";
}
$brief = $row['brief'];
echo "$brief<hr>";
}
endif;