-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.php
89 lines (75 loc) · 2.8 KB
/
dashboard.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
include 'auth.php'; // Include the authentication file to check if the user is logged in
requireLogin(); // Redirect to login page if not logged in
include 'config.php';
// Use the $conn variable from config.php for database connection
$result = $conn->query("SELECT * FROM car");
// Fetch all listings into an array
$listings = [];
while ($row = $result->fetch_assoc()) {
$listings[] = $row;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard - WheelsExchange</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>WheelsExchange</h1>
</header>
<nav>
<a href="index.php">Home</a>
<a href="listings.php">Listings</a>
<a href="dashboard.php">Dashboard</a>
<!-- Add more navigation links as needed -->
<!-- Logout link -->
<!-- Display user's profile picture and name -->
<div class="user-dropdown">
<div class="user-logo"> <!-- Add your user profile logo here -->
<!-- You can use an image or an icon for the user profile logo -->
<img src="https://logodix.com/logo/1984203.png" alt="User Logo">
</div>
<div class="user-menu">
<span class="username"><?php echo $user['username']; ?></span>
<div class="dropdown-content">
<a href="profile.php">Profile</a>
<a href="logout.php">Logout</a>
<a href="create_listing.php">List your Car</a>
</div>
</div>
</div>
</nav>
</nav>
<section class="container">
<h2 class="listhead">Available Listings</h2>
<div class="listing-container">
<?php
if (empty($listings)) {
echo '<p>No listings available at this moment.</p>';
} else {
// Loop through each car listing and display information
foreach ($listings as $listing) {
echo '<div class="listing-card">';
echo '<img src="car_images/' . $listing['image_filename'] . '" alt="Car Image">';
echo '<div class="listing-details">';
echo '<h3>' . $listing['make'] . ' ' . $listing['model'] . ' (' . $listing['year'] . ')</h3>';
echo '<p>Price: $' . $listing['price'] . '</p>';
echo '<p>Description: ' . $listing['description'] . '</p>';
// Add more details if needed
echo '</div>';
echo '</div>';
}}
?>
</div>
<!-- Add more content or dynamic elements as needed -->
</section>
<footer>
<p>© <?php echo date("Y"); ?> WheelsExchange. All rights reserved.</p>
</footer>
</body>
</html>