-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_listings.php
More file actions
71 lines (70 loc) · 2.55 KB
/
admin_listings.php
File metadata and controls
71 lines (70 loc) · 2.55 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
68
69
70
71
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
header("Location: Practical_13_Login.html");
exit();
}
$conn = new mysqli("localhost", "root", "Heleninh@2022", "HAC_Services");
$result = $conn->query("
SELECT listings.id, listings.title, listings.description, listings.price, listings.location, listings.status, users.name AS broker_name
FROM listings
JOIN users ON listings.broker_id = users.id
");
?>
<!DOCTYPE html>
<html>
<head>
<title>Moderate Listings</title>
<style>
body { font-family: Arial; background: #f0f0f0; padding: 20px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 10px; border: 1px solid #ccc; text-align: left; }
th { background: #2196f3; color: white; }
tr:nth-child(even) { background: #f9f9f9; }
.action-btn {
padding: 6px 12px;
margin: 0 4px;
border: none;
color: white;
border-radius: 4px;
cursor: pointer;
}
.approve { background: #4caf50; }
.delete { background: #f44336; }
</style>
</head>
<body>
<h2>Moderate Listings</h2>
<table>
<tr>
<th>ID</th>
<th>Title</th>
<th>Broker</th>
<th>Description</th>
<th>Price</th>
<th>Location</th>
<th>Status</th>
<th>Actions</th>
</tr>
<?php while($row = $result->fetch_assoc()): ?>
<tr>
<td><?= $row['id'] ?></td>
<td><?= htmlspecialchars($row['title']) ?></td>
<td><?= htmlspecialchars($row['broker_name']) ?></td>
<td><?= htmlspecialchars($row['description']) ?></td>
<td>$<?= $row['price'] ?></td>
<td><?= htmlspecialchars($row['location']) ?></td>
<td><?= $row['status'] ?></td>
<td>
<form action="moderate_listing_action.php" method="post" style="display:inline;">
<input type="hidden" name="id" value="<?= $row['id'] ?>">
<button type="submit" name="action" value="approve" class="action-btn approve">Approve</button>
<button type="submit" name="action" value="delete" class="action-btn delete" onclick="return confirm('Delete this listing?');">Delete</button>
</form>
</td>
</tr>
<?php endwhile; ?>
</table>
</body>
</html>
<?php $conn->close(); ?>