-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
67 lines (63 loc) · 1.58 KB
/
search.php
File metadata and controls
67 lines (63 loc) · 1.58 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
<?php
$conn = mysqli_connect('localhost', 'root', '', 'project');
if (!$conn) {
die("Connection failed: ".mysqli_connect_err());
}
$output = '';
if(isset($_POST["query"]))
{
$search = mysqli_real_escape_string($conn, $_POST["query"]);
$query = "
SELECT * FROM users
WHERE Name LIKE '%".$search."%'
OR Surname LIKE '%".$search."%'
OR Email LIKE '%".$search."%'
OR Username LIKE '%".$search."%'
OR Rank LIKE '%".$search."%'
";
}
else
{
$query = "
SELECT * FROM users ORDER BY Name asc
";
}
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<div class=""wrapper>
<div class="col-md-10 custyle">
<table class="table table-striped custab">
<thead>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Email address</th>
<th>Username</th>
<th>Rank</th>
<th class="text-center">Action</th>
</tr>
</thead>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["Name"].'</td>
<td>'.$row["Surname"].'</td>
<td>'.$row["Email"].'</td>
<td>'.$row["Username"].'</td>
<td>'.$row["Rank"].'</td>
<td class="text-center">
<a class="btn-edit btn btn-info btn-xs" href="#">
<span class=" glyphicon glyphicon-edit "></span> Edit</a>
<a href="#" class="btn-remove btn btn-danger btn-xs">
<span class="glyphicon glyphicon-remove"></span> Del</a></td>
</tr>
</div>
';
}
echo $output;
}
?>