This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsearch.php
60 lines (60 loc) · 1.91 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once 'init.php';
if (!$currentUser) {
header('Location: index.php');
exit();
}
include 'header.php';
$users = null;
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == "GET") {
$success = true;
if (isset($_GET['keyword'])) {
$users = searchUsers((!isset($_GET['keyword']) ? null : $_GET['keyword']));
}
if ($users==null){
$success = false;
}
}
?>
<div class="inner">
<?php if (!$success): ?>
<div class="alert alert-success" role="alert">
Không tìm thấy người dùng !
</div>
<?php endif; ?>
<?php function searchUsers($name)
{
$listUser = searchUserByName($name);
if(count($listUser) == 0) {
return null;
}
?>
<?php foreach ($listUser as $usr) : ?>
<div class="row">
<div class="col-12 mt-3">
<div class="card">
<div class="card-body p-3">
<div class="d-flex">
<div class="img-square-wrapper mr-2">
<a href="#">
<img class="rounded-circle" style="width:50px;height:50px;"
src="<?php echo empty($usr['avatarImage']) ? './assets/images/default-avatar.jpg' : 'view-image.php?userId=' . $usr['id'] ?>"
alt="<?php echo $usr['displayName'] ?>">
</a>
</div>
<div>
<a href="./profile.php?id=<?php echo $usr['id']; ?>" class="text-success">
<h5 class="card-title mb-1 vertical-center"><?php echo $usr['displayName'];?></h5>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; return "1";?>
<?php } ?>
</div>
<?php include 'footer.php'?>