D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
ashwika.encodersunlimited.com
/
Filename :
products.php
back
Copy
<?php require('style.php'); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Products</title> <style> /* Basic styling for product display */ .product-container { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; } .product-item { border: 1px solid #ddd; border-radius: 5px; overflow: hidden; width: 300px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .product-item img { width: 100%; height: 200px; object-fit: cover; } .product-content { padding: 15px; } .product-title { font-size: 1.25rem; margin: 0; } .product-description { margin: 10px 0; font-size: 1rem; color: #666; } .product-price { font-size: 1.2rem; color: #333; } .view-details { text-align: right; } .view-details a { color: #007BFF; text-decoration: none; } </style> </head> <body> <?php require('header.php'); ?> <div class="section-title text-center mt-5"> <h2 class="title">Our Latest Products</h2> <p class="sub-title">Select from our exclusive ranges</p> </div> <div class="product-container"> <?php // Include the database connection require('config.php'); // Fetch all products from the database $query = "SELECT id, name, description, image, price FROM products"; $result = $conn->query($query); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { ?> <div class="product-item"> <img src="ashadminwika/uploads/<?php echo htmlspecialchars($row['image']); ?>" alt="<?php echo htmlspecialchars($row['name']); ?>"> <div class="product-content"> <h2 class="product-title"><?php echo htmlspecialchars($row['name']); ?></h2> <p class="product-description"><?php echo substr(htmlspecialchars($row['description']), 0, 100) . '...'; ?></p> <p class="product-price">Rs <?php echo htmlspecialchars($row['price']); ?></p> <div class="view-details"> <a href="product-details.php?id=<?php echo $row['id']; ?>">View Details</a> </div> </div> </div> <?php } } else { echo "<p>No products found.</p>"; } // Close the database connection $conn->close(); ?> </div> <?php require('footer.php') ?> </body> </html>