Untitled
unknown
plain_text
2 years ago
2.5 kB
11
Indexable
<?php require 'vendor/autoload.php'; use GuzzleHttp\Client; $dummyDataUrl = 'https://dummyjson.com/products'; $client = new Client(); $response = $client->get($dummyDataUrl); $products = json_decode($response->getBody(), true); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Stylish Product List</title> <style> body { font-family: Arial, sans-serif; background-color: #f4f4f4; margin: 0; padding: 0; } .product-list { display: flex; flex-wrap: wrap; justify-content: space-around; padding: 20px; } .product-card { background-color: #fff; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); margin: 10px; padding: 20px; border-radius: 8px; width: 300px; text-align: center; height: 100%; display: flex; flex-direction: column; } .product-card h2, .product-card p, .product-card img { flex-grow: 1; } .product-image { max-width: 100%; height: auto; flex-grow: 0; margin-bottom: 10px; } .product-images { display: flex; justify-content: space-around; align-items: center; flex-grow: 1; } .product-images img { max-width: 100px; height: auto; } </style> </head> <body> <h1 style="text-align: center;">Stylish Product List</h1> <div class="product-list"> <?php foreach ($products['products'] as $product): ?> <div class="product-card"> <h2><?= $product['title'] ?></h2> <p>Description: <?= $product['description'] ?></p> <p>Price: $<?= $product['price'] ?></p> <p>Discount: <?= $product['discountPercentage'] ?>%</p> <p>Rating: <?= $product['rating'] ?></p> <p>Stock: <?= $product['stock'] ?></p> <p>Brand: <?= $product['brand'] ?></p> <p>Category: <?= $product['category'] ?></p> <img src="<?= $product['thumbnail'] ?>" alt="<?= $product['title'] ?> Thumbnail"> <div class="product-images"> <?php foreach ($product['images'] as $image): ?> <img src="<?= $image ?>" alt="<?= $product['title'] ?> Image"> <?php endforeach; ?> </div> </div> <?php endforeach; ?> </div> </body> </html>
Editor is loading...
Leave a Comment