-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfind.php
114 lines (109 loc) · 2.56 KB
/
find.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
<?php
session_start();
if(empty($_SESSION['username']))
{
header("Location:signup.php");
}
else {
$name=$_SESSION['username'];
}
$servername = "localhost";
$username = "root";
$password = "AthlonY2";
$dbname = "Platform";
$i=0;
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT name FROM SIGNUP";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
if($row["name"]!=$name)
{ $frnd[$i]=$row["name"];
$i++;
}
}
}
?>
<html>
<head>
<style>
ol
{
list-style-type: circle;
}
li
{
cursor: pointer;
width: auto;
}
li:hover
{
color: #939393;
width: auto;
}
</style>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href=decorate.css>
<body id="body">
<ul>
<li>
<a><?php echo $name?></a>
<ul class="dropdown">
<li><a href="signup.php">Log out</a></li>
<li><a href="homepage.php">Homepage</a></li>
<li><a href="find.php">Find Friends</a></li>
</ul>
</li>
</ul>
<input autofocus type="search" onkeyup="search()" id="input"></input>
</body>
<script>
var frnd= <?php echo json_encode($frnd); ?>;
var a=document.createElement("OL");
a.setAttribute("id", "myOL");
document.body.appendChild(a);
var i=0;
for(i=0;i<frnd.length;i++)
{
var y = document.createElement("LI");
y.setAttribute("id",i);
var t1 = document.createTextNode(frnd[i]);
y.appendChild(t1);
document.getElementById("myOL").appendChild(y);
var f1 = document.getElementById(i);
f1.addEventListener("click",modify);
}
function modify(e)
{
var id=e.target.id;
var send=document.getElementById(id).innerHTML;
window.location.href = "chat.php?id="+send;
}
function search()
{
var z=document.getElementById("myOL");
document.body.removeChild(z);
var a=document.createElement("OL");
a.setAttribute("id", "myOL");
document.body.appendChild(a);
var search=document.getElementById('input').value;
i=0;
for(i=0;i<frnd.length;i++)
{
if(frnd[i].indexOf(search) !== -1)
{ var y = document.createElement("LI");
y.setAttribute("id",i);
var t1 = document.createTextNode(frnd[i]);
y.appendChild(t1);
document.getElementById("myOL").appendChild(y);
var f1 = document.getElementById(i);
f1.addEventListener("click",modify);
}
}
}
</script>