-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewuser_2.php
56 lines (54 loc) · 1.58 KB
/
viewuser_2.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
<?php include 'connection.php';?>
<?php
session_start();
if(!($_SESSION['logged_in'])){
//$_SESSION['header_loc']="adminhome.php";
session_unset();
session_destroy();
header('Location: login.php');
}
?>
<?php
if(!empty($_REQUEST['new_role']))
$new_role=$_REQUEST['new_role'];
else
$new_role="";
$str=$fltr_str;
$sql_arr= array("all"=>"SELECT * FROM login",
"filter"=>"SELECT * FROM login WHERE Username LIKE '%$str%'
OR Email LIKE '%$str%'
OR Role LIKE '%$str%' ORDER BY SNo",
"update"=>"UPDATE login SET Role=$new_role WHERE SNo=$id");
$sql=$sql_arr[$q];
$result = $conn->query($sql);
if($id>0){
$sql=$sql_arr["sortnfilter"];
$result = $conn->query($sql);
}
echo "<table>
<tr>
<th>SNo</th>
<th>Username</th>
<th>Email</th>
<th>Role</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
$sno=$row['SNo'];
$role=$row['Role'];
//echo '$role';
//if($role=='admin'){ echo'selected';}
//if($role=='guest'){ echo'selected';}
echo "<td>" . $row['SNo'] . "</td>";
echo "<td>" . $row['Username'] . "</td>";
echo "<td>" . $row['Email'] . "</td>";
echo "<td>" . "<select name='roles' onchange='role_func(this.value,$sno)'>";
?>
<option value='admin' <?php if( $role =='admin') {echo "selected"; }?> >Administrator</option>
<option value='employee' <?php if( $role =='employee'){ echo "selected";} ?>>Employee</option>
<option value='guest' <?php if( $role =='guest') { echo "selected"; }?>>Guest</option>
<?php
echo "</tr>";
}
echo "</table>";
?>