Repository navigation
Expand file tree
/
Copy pathdashboard.php
More file actions
executable file
·50 lines (44 loc) · 1.6 KB
/
Copy pathdashboard.php
File metadata and controls
executable file
·50 lines (44 loc) · 1.6 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
<?php
session_start();
include('config.php');
include('sessioncheck.php'); // Ensures user is logged in
include('header.php');
$userName = isset($_SESSION['log']['name']) ? explode(' ', $_SESSION['log']['name'])[0] : 'User';
?>
<div class="dashboard-header">
<h1 class="dashboard-title">Welcome, <?php echo htmlspecialchars($userName); ?>!</h1>
<p class="dashboard-subtitle">Here's the current status of all parking lots.</p>
</div>
<div class="parking-grid">
<?php
$qry = mysqli_query($conn, "SELECT * FROM lot ORDER BY id ASC");
while ($row = mysqli_fetch_assoc($qry)) {
$lot_status = $row['status'];
$lot_name = $row['lotname'];
$card_class = '';
$link = '#';
$link_text = htmlspecialchars($lot_status);
if ($lot_status == 'Free') {
$card_class = 'status-free';
$link = 'book.php';
$link_text = 'Book Now';
} elseif ($lot_status == 'Leaving') {
$card_class = 'status-leaving';
} else { // Booked or Ongoing Booking
$card_class = 'status-booked';
}
?>
<a href="<?php echo $link; ?>" class="parking-card <?php echo $card_class; ?>" style="text-decoration: none; color: inherit;">
<div class="card-content">
<span class="lot-name">Lot <?php echo htmlspecialchars($lot_name); ?></span>
<span class="lot-status"><?php echo htmlspecialchars($lot_status); ?></span>
<div class="card-action"><?php echo $link_text; ?></div>
</div>
</a>
<?php
}
?>
</div>
<?php
include('footer.php');
?>