/
search_results.php
324 lines (292 loc) · 11.6 KB
/
search_results.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
<?php
include "dbconnect.php";
include "members_only.php";
?>
<?php
$gender = null;
$min_age = null;
$max_age = null;
$city = null;
// expand part
$min_height = null;
$max_height = null;
$education = null;
if(isset($_POST['search'])||isset($_POST['advanced_search'])){
$gender = $_POST['gender'];
$min_age = $_POST['min_age'];
$max_age = $_POST['max_age'];
$city = $_POST['city'];
$query_city = ($city=="Any"||$city==null)?'':' AND city="'.$city.'"';
$date=date_create();
date_add($date,date_interval_create_from_date_string('-'.$max_age.' years'));
$bday_lowbound = date_format($date, "Y-m-d");
$query_bday_lowbound= ($max_age==0)?'':' AND birthdate >="'.$bday_lowbound.'"';
$date=date_create();
date_add($date,date_interval_create_from_date_string('-'.$min_age.' years'));
$bday_upbound = date_format($date, "Y-m-d");
$query_bday_upbound= ($min_age==0)?'':' AND birthdate <="'.$bday_upbound.'"';
// expand part
if(isset($_POST['advanced_search'])){
$min_height = $_POST['min_height'];
$max_height = $_POST['max_height'];
$education = $_POST['education'];
}
$query_min_height = ($min_height==0)?'':' AND height>='.$min_height;
$query_max_height = ($max_height==0)?'':' AND height<='.$max_height;
$query_education = ($education=="Any"||$education==null)?'':' AND education="'.$education.'"';
$query = 'SELECT * FROM users_account WHERE userID <> '.$_SESSION['valid_userID'].$query_bday_lowbound.$query_bday_upbound.' and gender="'.$gender.'" '.$query_city.' '.$query_min_height.$query_max_height.$query_education;
echo $query;
} else {
$row = get_basic_info($_SESSION["valid_userID"], $db);
$gender = ($row['gender']=="Male")?"Female":"Male";
$query = 'SELECT * FROM users_account WHERE gender="'.$gender.'"';
}
?>
<html>
<head>
<title>Search Results</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" href="css/search_results.css">
<script src="JS/showHide.js"></script>
</head>
<body>
<!-- top banner -->
<div class="banner" id="banner_top">
<a href="index.php"><img src="img/logo.png" height="120" width="160" style="margin-left: 11.5%"></a>
<nav>
<a href="index.php">Home</a>
<a href="inbox.php">Inbox</a>
<a href="profile.php">My heydate</a>
<a href="search_results.php">Search</a>
<a href="logout.php">Log out</a>
</nav>
</div>
<!-- main body -->
<div class="container">
<!-- <div class="section_container" id="search_bar">Search Bar Here</div> -->
<div class="sub_container left main">
<!-- search selector -->
<form class="section_container" id="search_selector" action="search_results.php?advanced_search=1" method="post">
<div class="wrapper">
<div class="left" style="margin-top:5">
<select name="gender">
<option value="Male" <?php echo $gender=='Male'?'selected':''; ?> >Male</option>
<option value="Female" <?php echo $gender=='Female'?'selected':''; ?> >Female</option>
</select>
from
<select name="min_age">
<option value=0 >Any</option>
<?php
for($i=1; $i<=40 ; $i++){
echo '<option value="'.$i.'"';
if($i==$min_age)
echo 'selected';
echo '>'.$i.'</option>';
}
?>
</select>
to
<select name="max_age">
<option value=0 >Any</option>
<?php
for($i=1; $i<=40 ; $i++){
echo '<option value="'.$i.'"';
if($i==$max_age)
echo 'selected';
echo '>'.$i.'</option>';
}
?>
</select>
in
<select name="city" id="listBox" required="required">
<?php foreach($Cities as $citytmp){
echo '<option value='.$citytmp.(($citytmp==$city)?' selected':'').'>'.$citytmp.'</option>';
} ?>
</select>
</div>
<button class="right" type="submit" name="advanced_search">Search</button>
<button type="button" class="right" id="more_button" onclick="showHide('expand')">more</button>
</div>
<div id="expand" class="clear" style="display:none">
Height from
<select name="min_height">
<option value=0 >Any</option>
<?php
for($i=100; $i<=250 ; $i+=10){
echo '<option value="'.$i.'"';
if($i==$min_height)
echo 'selected';
echo '>'.$i.'</option>';
}
?>
</select>
cm to
<select name="max_height">
<option value=0 >Any</option>
<?php
for($i=100; $i<=250 ; $i+=10){
echo '<option value="'.$i.'"';
if($i==$max_height)
echo 'selected';
echo '>'.$i.'</option>';
}
?>
</select>
cm Education
<select name="education" id="listBox" required="required">
<?php foreach($Educations as $edutmp){
echo '<option value='.$edutmp.(($edutmp==$education)?' selected':'').'>'.$edutmp.'</option>';
} ?>
</select>
</div>
</form>
<!-- <div id="search">
<h2>Advanced Search</h2>
<form action="search_results.php?advanced_search=1" method="post">
Gender:<br />
<input type="radio" name="gender" value="Male" <?php
// echo $gender=='Male'?'checked':''; ?>> Male
<input type="radio" name="gender" value="Female" <?php
// echo $gender=='Female'?'checked':''; ?>> Female
<br />
Age:<br />
<input type="number" name="age" size="40" value = <?php
// echo $age; ?>>
<br />
Height:<br />
<input type="number" name="height" size="40" value = 170>
<br />
Education:<br />
<input type=text name="education" value="education">
<br/>
City:
<select name="city" id="listBox" required="required">
<?php
// foreach($Cities as $citytmp){
// echo '<option value='.$citytmp.(($citytmp==$city)?' selected':'').'>'.$citytmp.'</option>';} ?>
</select>
<br />
Description:<br />
<textarea name='description' rows="4" cols="50">beautiful
</textarea>
<br />
<input type="submit" name="search" value="Search">
</form>
</div> -->
<div class="section_container">
<?php
$result = $db->query($query);
if($result->num_rows>0){
while($row = $result->fetch_assoc()){
// echo '<a href="browse_profile.php?customerID='.$row['userID'].'">';
// echo '<div id = "users">';
// echo '<img src="users_profile_photo/'.
// ($row['profilePhoto']!=Null?$row['profilePhoto']:'default_'.$row['gender'].'.jpg').'" height="80">';
// echo $row['name'].'<br/>'.
// $row['city'].'<br/>'.
// $row['height'].'<br/>'.
// $row['education'].'<br/>';
// echo "</div></a>";
echo '
<div class="result_box left">
<a href="profile.php?customerID='.$row['userID'].'" ><div class="image_container_100" style="background-image: url(users_profile_photo/'.($row['profilePhoto']!=Null?$row['profilePhoto']:'default_'.$row['gender'].'.jpg').');"></div></a>
<div class="profile_summary">
<label id="profile_name">'.$row['name'].'</label>
<div>'.cal_age($row['birthdate']).', '.$row['city'].', '.$row['education'].', '.$row['height'].'cm</div>
</div>
</div>
';
}
}else{
echo 'Found nothing';
}
?>
</div>
</div>
<!-- left part end -->
<!-- sidebars -->
<div class="sub_container right clear_right sidebar">
<?php
include "right_record_bar.php";
?>
<label>Matched</label>
<div class="clear">
<?php
if ($match_result->num_rows>0) {
while($row = $match_result->fetch_assoc()){
echo '<a href="profile.php?customerID='.$row['userID'].'">';
echo '<div class="left small_img image_container_60" style="background-image: url(users_profile_photo/'.($row['profilePhoto']!=Null?$row['profilePhoto']:'default_'.$row['gender'].'.jpg').');"></div> ';
echo "</a>";
}
} else {
echo "<br><label>No one has matched with you yet.</label>";
}
?>
</div>
</div>
<div class="sub_container right clear_right sidebar">
<label>They Viewed Me</label>
<div class="clear">
<?php
if ($viewyou_result->num_rows>0) {
while($row = $viewyou_result->fetch_assoc()){
echo '<a href="profile.php?customerID='.$row['userID'].'">';
echo '<div class="left small_img image_container_60" style="background-image: url(users_profile_photo/'.($row['profilePhoto']!=Null?$row['profilePhoto']:'default_'.$row['gender'].'.jpg').');"></div> ';
echo "</a>";
}
} else {
echo "<br><label>No one has viewed you yet.</label>";
}
?>
</div>
</div>
<div class="sub_container right clear_right sidebar">
<label>I Viewed Them</label>
<div class="clear">
<?php
if ($youview_result->num_rows>0) {
while($row = $youview_result->fetch_assoc()){
echo '<a href="profile.php?customerID='.$row['userID'].'">';
echo '<div class="left small_img image_container_60" style="background-image: url(users_profile_photo/'.($row['profilePhoto']!=Null?$row['profilePhoto']:'default_'.$row['gender'].'.jpg').');"></div> ';
echo "</a>";
}
} else {
echo "<br><label>You have not viewed anyone yet.</label>";
}
?>
</div>
</div>
<div class="sub_container right clear_right sidebar recommend">
<label>Recommend</label>
<div class="clear">
<?php
if ($recommend_result->num_rows>0) {
while($row = $recommend_result->fetch_assoc()){
echo '<div class="findlover_box left">';
echo '<a href="profile.php?customerID='.$row['userID'].'">';
echo '<div class="image_container_100" style="background-image: url(users_profile_photo/'.($row['profilePhoto']!=Null?$row['profilePhoto']:'default_'.$row['gender'].'.jpg').');"></div> ';
echo "</a>";
echo '
<div class="left profile_summary">
<label class="left" id="profile_name">'.$row['name'].'</label>
<div class="clear_left">'.cal_age($row['birthdate']).', '.$row['city'].', '.$row['education'].', '.$row['height'].'cm</div>
</div>
</div>
';
}
} else {
echo "<br><label>No recommend for you yet.</label>";
}
?>
</div>
</div>
<!-- side bars end -->
</div>
<!-- main body end -->
<!-- footer -->
<div class="banner" id="banner_footer">
<mistral>"We accept the love we think we deserve."</mistral><br>
copyright © heydate.com 2015
</div>
</body>
</html>