-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
194 lines (170 loc) · 11 KB
/
search.php
File metadata and controls
194 lines (170 loc) · 11 KB
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
<?php include 'config.php';
$search = isset($_REQUEST['searchVal']) ? htmlentities($_REQUEST['searchVal']) : '';
?>
<!DOCTYPE html>
<html>
<head>
<title>Search <?php include 'includes/title.php'; ?></title>
<link href="assets/css/bootstrap.css" rel='stylesheet' type='text/css' />
<!-- Custom Theme files -->
<link href="assets/css/style.css" rel="stylesheet" type="text/css" media="all" />
<!-- Custom Theme files -->
<?php include 'includes/stylesheets.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<div class="container">
<div class="total-info">
<?php include 'includes/left_panel.php'; ?>
<div class="col-md-7 grid_2">
<?php
$q=$conn->prepare("
SELECT * FROM (SELECT userImg as one,instituteName as two,u.userID as id,$name,'users_table' AS comes_from FROM users AS u
LEFT JOIN users_edu AS e USING (userID)
WHERE (firstName LIKE :search OR lastName LIKE :search OR instituteName LIKE :search) AND u.userID!='".$userid."'
UNION
SELECT eventImg as one,eventDate as two,eventID as id,eventName as name,'user_events_table' AS comes_from FROM user_events
WHERE eventName LIKE :search OR eventDetails LIKE :search OR eventLocation LIKE :search OR eventDate LIKE :search
UNION
SELECT groupImg as one,createTime as two,groupID as id,groupName as name,'user_groups_table' AS comes_from FROM user_groups
WHERE groupName LIKE :search
UNION
SELECT tittle as one,fq.createTime as two,fqID as id,$name,'forum_questions' AS comes_from FROM forum_questions AS fq
LEFT JOIN users AS u USING (userID)
WHERE tittle LIKE :search OR description LIKE :search
)x ORDER BY name ASC
");
$q->bindValue(':search','%'.$search.'%');
$q->execute();
$count=$q->rowCount();
?>
<div class="white-area"><h5>
<a href="javascript:void(0);" rel="people" data-search="<?php echo $search; ?>" class="click_searchBy">People</a> |
<a href="javascript:void(0);" rel="event" data-search="<?php echo $search; ?>" class="click_searchBy">Event</a> |
<a href="javascript:void(0);" rel="group" data-search="<?php echo $search; ?>" class="click_searchBy">Group </a> |
<a href="javascript:void(0);" rel="question" data-search="<?php echo $search; ?>" class="click_searchBy">Question </a></h5>
</div>
<div class="profile_container">
<div id="show_search"></div>
<ul class="cute <?php if($count>10){echo 'scroll';} ?>" id="default_search" style="width: 100%;">
<li><?php if($search==''){echo 'Search Result: Empty search value';}else { ?></li>
<li>Search Result: <?php echo '<b>"'.$search.'"</b></li><hr>';
if($count==''){echo 'No record found';}{
while ($row_search = $q->fetch(PDO::FETCH_ASSOC)) { //echo $row_search['comes_from']; ?>
<!--For People-->
<?php if($row_search['comes_from']=='users_table'){
//cheching if frnd req is sent
$sql_req_sent=mysqli_query($dbconfig,"SELECT * FROM friend_request
WHERE friendWith='".$row_search['id']."' AND userID='".$userid."'") or die(mysqli_error($dbconfig));
$check_req_sent=mysqli_num_rows($sql_req_sent);
$check_req_sent = isset($check_req_sent) ? htmlentities($check_req_sent) : '';
//checking if are friends
$sql_my_frnds=mysqli_query($dbconfig,"SELECT * FROM my_friends
WHERE userID='".$row_search['id']."' AND friendWith='".$userid."' or
friendWith='".$row_search['id']."' AND userID='".$userid."'") or die(mysqli_error($dbconfig));
$row_my_frnds=mysqli_fetch_assoc($sql_my_frnds);
$check_my_frnd=mysqli_num_rows($sql_my_frnds);
$check_my_frnd = isset($check_my_frnd) ? htmlentities($check_my_frnd) : '';
?>
<li style="padding:0px;">
<img src="<?php if($row_search['one']==''){echo 'images/default.jpg';}else {
echo 'uploads/'.$row_search['one']; } ?>" alt="User Avatar" class="recent_chat" style="margin-top: 10px;">
<div class="user_info">
<small><b><a href="user/<?php echo ''.$row_search["id"].'';?>"><?php echo $row_search['name']; ?></a></b></small>
<small class="grey1"><?php echo $row_search['two']; ?></small>
</div>
<?php //check if frnd req sent
if($check_req_sent==true){ ?>
<span id="right_btn" class="btn btn-default btn-sm"><i class="icon-ok"></i> Sent</span> <?php }
//check if already driends
else if($check_my_frnd==true) {
echo '<span id="right_btn" class="btn btn-default btn-sm"><i class="icon-ok"></i> Friends</span>';
//else show add friend button
}else { ?>
<div id="right_btn"><span id="req_sent<?php echo $row_search['id']; ?>"></span> </div>
<span id="add_frnd<?php echo $row_search['id']; ?>">
<a href="javascript:void(0);" rel="<?php echo $row_search['id']; ?>" class="click_add_friend btn btn-default btn-sm" id="right_btn"><i class="icon-plus"></i> Add as Friend</a>
</span>
<?php } ?>
<hr>
</li>
<?php } ?>
<?php if($row_search['comes_from']=='user_events_table') {
//checking status
$sql_check_if_req=mysqli_query($dbconfig,"SELECT * FROM event_status
WHERE userID='".$userid."' AND eventID='".$row_search['id']."'");
$row_status=mysqli_fetch_assoc($sql_check_if_req);
?>
<!--For Event-->
<li style="padding:0px;">
<img src="<?php if($row_search['one']==''){echo 'images/event.jpg';}else {
echo 'uploads/'.$row_search['one']; } ?>" alt="Avatar" class="recent_chat" style="margin-top: 10px;">
<div class="user_info">
<small><b><a href="event/<?php echo $row_search['id']; ?>"><?php echo $row_search['name']; ?></a></b></small>
<small class="grey1"><?php echo date('d-M-Y',strtotime($row_search['two'])); ?></small>
</div>
<?php
//check if attending
if($row_status['status']=='Attending') {
echo '<span id="right_btn" class="btn btn-default btn-sm"><i class="icon-ok"></i> Attending</span>'; }
//check if Declined
else if($row_status['status']=='Declined') {
echo '<span id="right_btn" class="btn btn-default btn-sm"><i class="icon-ok"></i> Declined</span>';
//else show add friend button
}else if($row_status['status']=='Interested') {
echo '<span id="right_btn" class="btn btn-default btn-sm"><i class="icon-ok"></i> Interested</span>';
} ?>
<hr>
</li>
<?php } ?>
<?php if($row_search['comes_from']=='user_groups_table') {
//check if member
$sql_access=mysqli_query($dbconfig,"SELECT * FROM user_groups AS g LEFT JOIN group_members USING (groupID)
WHERE g.groupID='".$row_search['id']."' AND memberID='".$userid."' ") or die (mysqli_error($dbconfig));
$check_access_of_group=mysqli_num_rows($sql_access);
$check_access_of_group = isset($check_access_of_group) ? htmlentities($check_access_of_group) : '';
?>
<!--For Group-->
<li style="padding:0px;">
<img src="<?php if($row_search['one']==''){echo 'images/group.jpg';}else {
echo 'uploads/'.$row_search['one']; } ?>" alt="Avatar" class="recent_chat" style="margin-top: 10px;">
<div class="user_info">
<small><b><a href="group/<?php echo $row_search['id']; ?>"><?php echo $row_search['name']; ?></a></b></small>
</div>
<?php
//check if member
if($check_access_of_group==true) {
echo '<span id="right_btn" class="btn btn-default btn-sm"><i class="icon-ok"></i> Member</span>'; }
?>
<hr>
</li>
<?php } ?>
<?php if($row_search['comes_from']=='forum_questions') {
$sql_question=mysqli_query($dbconfig,"SELECT * FROM forum_questions WHERE fqID='".$row_search['id']."'");
$row_question=mysqli_fetch_assoc($sql_question);
?>
<li style="display:flex; width:100%">
<i class="icon-ok <?php if($row_question['answerAccepted']=='1'){echo 'ok_green';}else{echo 'ok_grey';} ?>"></i>
<span class="inline_grid">
<b><a href="question/<?php echo $row_search['id']; ?>/<?php echo urlencode($row_search['one']); ?>"><?php echo ($row_search['one']); ?></a></b>
<small class="grey1">Asked by:
<a href="<?php echo 'user/'.$row_question["userID"].'';?>"><?php echo $row_search['name']; ?></a> |
<?php echo "" . humanTiming($row_search['two']). " ago"; ?>
</small>
</span>
<hr></li>
<?php } ?>
<?php }}} ?>
</ul>
</div>
</div><!--end col-md-4-->
<?php include 'includes/right_panel.php'; ?>
<!--Container Ends Here-->
<div class="clearfix"></div>
</div>
<script src="assets/js/myscript.js"></script>
<script src="assets/js/ajax_load.js"></script>
<script src="assets/my-js/friend_request.js"></script>
</div>
</body>
</html>