forked from Jmurrietasmith/EqManage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchUser.php
73 lines (56 loc) · 1.94 KB
/
searchUser.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
<?php
session_start();
if(!isset($_SESSION['loggedin'])){
header('Location: login.php');
exit();
}
if ($_SESSION['username'] != 'administrator'){
header('Location: index.php?adminonly=1');
}
?>
<div id="user_button" class="tab-pane fade in active bootstrap-iso user" style="margin-top: 10px">
<div style="position: center" align="center" id="searchUser">
<label for="userSelect" style="margin-top: 20px">Search:</label>
<select id="userSelect" style="width: 20%; text-align: left;margin-bottom: 10px" onchange="change()">
<?php
$returnResult = mysqli_query($db,"select * from EqManage.users");
while ($row = mysqli_fetch_array($returnResult)){
echo "<option value=\"\">Select User</option>";
$userID = $row['id'];
$fullname = $row['fullname'];
echo "<option value='$userID'>ID: $userID | Name: $fullname</option>";
};
?>
</select>
</div>
</div>
<div id="user" class="tab-pane fade in active bootstrap-iso user" style="margin-top: 10px">
<?php
include ('fetchSearchUser.php');
?>
</div>
</div>
<script>
$(document).ready(function() {
$("#userSelect").change(function () {
var id = $(this).val();
console.log("Working");
var url = 'fetchSearchUser.php?' + 'id=' + id;
console.log(url);
$("#user").load(url);
console.log("Done");
})});
$("#userSelect").select2( {
placeholder: "Enter user ID",
allowClear: true,
} );
function change() {
var e = document.getElementById("userSelect");
var id = e.options[e.selectedIndex].value;
console.log(id);
var url = 'fetchSearchUser.php?' + 'id=' + id;
console.log(url);
$("#user").load(url);
console.log("Done");
}
</script>