-
Notifications
You must be signed in to change notification settings - Fork 0
/
callToAjax.php
97 lines (97 loc) · 3.86 KB
/
callToAjax.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
<?php
session_start();
//Including Database configuration file.
include 'classes/Database.class.php';
include 'classes/User.class.php';
//Getting value of "search" variable from "script.js".
if (empty($_POST['search']) === false) {
//Search box value assigning to $Name variable.
$Name = $_POST['search'];
//Search query.
$Query = "SELECT * FROM users WHERE Pseudo LIKE '%$Name%' ORDER BY Pseudo, Status";
//Query execution
$ExecQuery = MySQLi_query($con, $Query);
//Creating unordered list to display result.
echo '
<ul class="list">
';
//Fetching result from database.
while ($Result = MySQLi_fetch_array($ExecQuery)) {
?>
<!-- Creating unordered list items.
Calling javascript function named as "fill" found in "script.js" file.
By passing fetched result as parameter. -->
<li class="clearfix">
<?php if ($Result['Id'] !== $_SESSION['id']) { ?>
<div class="about">
<div class="regroup">
<div class="name">
<?= $Result['Pseudo'] ?>
</div>
<div class="status">
<i class="fa fa-circle online"></i> <?= $Result['Status'] ?>
</div>
</div>
<div class="infos hide">
<ul>
<li>Prénom: <?= $Result['FirstName'] ?></li>
<li>Nom: <?= $Result['LastName'] ?></li>
<li>Email: <?= $Result['Email'] ?></li>
</ul>
<button class="button-close">Fermer</button>
</div>
</div>
<?php } ?>
</li>
<script src="js/api.js"></script>
<!-- Below php code is just for closing parenthesis. Don't be confused. -->
<?php
}
echo '</ul>';
} else if (empty($_POST['search']) === true || $_POST['search'] === "") {
//Search box value assigning to $Name variable.
$Name = $_POST['search'];
//Search query.
$Query = "SELECT * FROM users ORDER BY Pseudo, Status";
//Query execution
$ExecQuery = MySQLi_query($con, $Query);
//Creating unordered list to display result.
echo '
<ul class="list">
';
//Fetching result from database.
while ($Result = MySQLi_fetch_array($ExecQuery)) {
?>
<!-- Creating unordered list items.
Calling javascript function named as "fill" found in "script.js" file.
By passing fetched result as parameter. -->
<div id="users">
<li class="clearfix">
<?php if ($Result['Id'] !== $_SESSION['id']) { ?>
<div class="about">
<div class="regroup">
<div class="name">
<?= $Result['Pseudo'] ?>
</div>
<div class="status">
<i class="fa fa-circle online"></i> <?= $Result['Status'] ?>
</div>
</div>
<div class="infos hide">
<ul>
<li>Prénom: <?= $Result['FirstName'] ?></li>
<li>Nom: <?= $Result['LastName'] ?></li>
<li>Email: <?= $Result['Email'] ?></li>
</ul>
<button class="button-close">Fermer</button>
</div>
</div>
<?php } ?>
</li>
</div>
<script src="js/api.js"></script>
<!-- Below php code is just for closing parenthesis. Don't be confused. -->
<?php
}
echo '</ul>';
} ?>