Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <body style="background-color:grey;text-align:center">
- <meta charset="utf-8">
- <title>Z's Jewelers</title>
- <link rel="stylesheet" href="productList.css">
- </head>
- <body>
- <h1>Z's Jewelers</h1>
- <ul class="product_list">
- <h2>Product List</h2>
- <?php
- $products = array(
- "1" => array(
- "name" => $title,
- "id" => $productID,
- "price" => $price,
- "description" => $description,
- "image" => $image,
- "alt" => "atocha shipwreck emerald cross",
- ),
- "2" => array(
- "name" => $title,
- "id" => $productID,
- "price" => $price,
- "description" => $description,
- "image" => $image,
- "alt" => "Vinetian inspired emerald cross",
- ),
- "3" => array(
- "name" => $title,
- "id" => $productID,
- "price" => $price,
- "description" => $description,
- "image" => $image,
- "alt" => "Gold Ruby eyed snake bracelet",
- ),
- "4" => array(
- "name" => $title,
- "id" => $productID,
- "price" => $price,
- "description" => $description,
- "image" => $image,
- "alt" => "Diamond encrusted Hublot watch",
- ),
- "5" => array(
- "name" => $title,
- "id" => $productID,
- "price" => $price,
- "description" => $description,
- "image" => $image,
- "alt" => "Replica of the blue titanic heart charm and necklace",
- ),
- );
- $servername = "localhost:3306";
- $username = "root";
- $password = "";
- $dbname = "ourdatabase";
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT productID, title, description, image, stock, price FROM PRODUCT";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- while($row = mysqli_fetch_assoc($result)) {
- $productID = $row['productID'];
- $title= $row['title'];
- $description = $row['description'];
- $image = $row['image'];
- $stock = $row['stock'];
- $price = $row['price'];
- }
- }
- mysqli_close($conn);
- ?>
- <?php
- foreach($products as $product) {
- $href="shoppingcart.php?productid=" . $product['id']
- . "&productname=" . $product['name']
- . "&price=" . $product['price']
- . "&quantity=1";
- echo '<li>
- <img src=" ' . $product['image'] . ' " alt=" ' .$product['alt'] . ' ">
- <div class="product_information">
- <h4>' . $product['name'] . '</h4>
- <span>' . $product['price'] . '</span>
- </div>
- <div class="product_description">
- <p>' . $product['description'] . '</p>
- <a href=" ' . $href .' "class="add_to_cart">Add to cart</a>
- </div>
- </li>';
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment