Skip to content

Commit da484a8

Browse files
Fix staff profile page to display correct user
information
1 parent db5f5a4 commit da484a8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

functions/views/staff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/profile.png"><?php echo $row['username']; ?></td>
1818
<td><?php echo $row['created_at']; ?></td>
1919
<td class="text-center">
20-
<a class="mx-1" href="profile-staff.php" role="button"><i class="far fa-eye" style="font-size: 20px;"></i></a>
20+
<a class="mx-1" href="profile-staff.php?id=<?php echo $row['id']?>" role="button"><i class="far fa-eye" style="font-size: 20px;"></i></a>
2121
<a class="mx-1" href="#" role="button" data-bs-target="#update" data-bs-toggle="modal" data-id="<?php echo $row['id']?>" data-username="<?php echo $row['username']?>"><i class="far fa-edit text-warning" style="font-size: 20px;"></i></a>
2222
<a class="mx-1" href="#" role="button" data-bs-target="#remove" data-bs-toggle="modal" data-id="<?php echo $row['id']?>"><i class="far fa-trash-alt text-danger" style="font-size: 20px;"></i></a>
2323
</td>

profile-staff.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
include_once 'functions/authentication.php';
33
include_once 'functions/connection.php';
44

5-
$id = $_SESSION['id'];
6-
$username = $_SESSION['username'];
5+
$id = $_GET['id'];
76
$sql = 'SELECT Transactions.id, Transactions.kilo, Transactions.total, Transactions.status, Transactions.created_at, users.username, customers.fullname
87
FROM Transactions
98
JOIN users ON Transactions.user_id = users.id
@@ -13,6 +12,15 @@
1312
$stmt->bindParam(':id', $id);
1413
$stmt->execute();
1514
$results = $stmt->fetchAll();
15+
16+
$sql = 'SELECT username
17+
FROM users
18+
WHERE id = :id';
19+
$stmt = $db->prepare($sql);
20+
$stmt->bindParam(':id', $id);
21+
$stmt->execute();
22+
$info = $stmt->fetch();
23+
$username = $info['username'] ?? 'None';
1624
?>
1725

1826
<!DOCTYPE html>

0 commit comments

Comments
 (0)