-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchBar.php
More file actions
84 lines (74 loc) · 2.39 KB
/
Copy pathsearchBar.php
File metadata and controls
84 lines (74 loc) · 2.39 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
<?php
/**
* Created by PhpStorm.
* User: Gabriel
* Date: 01/05/2018
* Time: 10:37
*/
include_once "borders.php";
if (!isset($_SESSION['id'])) {
header("Location: index.php");
exit();
}
$arrayID = null;
$idLoad = null;
?>
<div id="jquery">
<script>
$(document).ready(function () {
$(".member").click(function () {
var id = this.id;
//alert(id);
$.ajax({
url: "network.php",
type: "post",
data: {idLoad: id}
}).done(function () {
window.location.href = "network.php";
});
});
});
</script>
</div>
<?php
$string = mysqli_real_escape_string($conn, $_POST["searchBarField"]);
if (empty($string)) {
header("Location: home.php?error=emptySearch");
exit();
} else {
$string = '%' . $string . '%';
$sql = "SELECT IDUser FROM `user` WHERE NameUser LIKE '$string' OR FirstNameUser LIKE '$string' OR MailUser LIKE '$string' OR Pseudo LIKE '$string'";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
if (!($row['IDUser'] == $_SESSION['id'])) {
$arrayID[] = $row['IDUser'];
}
}
?>
<link href="bootstrap/css/network.css" rel="stylesheet">
<div class="members">
<?php
if ($arrayID != null) {
foreach ($arrayID as $id) {
$sql = "SELECT Pseudo, PP FROM `user` WHERE IDUser = $id";
$result = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_assoc($result)) {
$sql2 = "SELECT Path FROM user INNER JOIN media ON media.IDMedia = PP WHERE IDUser = '$id'";
$result2 = mysqli_query($conn, $sql2);
if ($row2 = mysqli_fetch_assoc($result2)) {
$idLoad = $id;
?>
<div class="member" id="<?php echo $id; ?>">
<img src="<?php echo $row2['Path'] ?>" class="friendPic">
<p class="nameFriend"><?php echo $row['Pseudo'] ?></p>
</div>
<?php
}
}
}
}
?>
</div>
<?php
}
include_once "footer.php";