Guest User

Untitled

a guest
Mar 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.95 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head> 
  4.     <body style="background-color:grey;text-align:center">
  5.         <meta charset="utf-8">
  6.         <title>Z's Jewelers</title>
  7.         <link rel="stylesheet" href="productList.css">
  8.         </head>
  9.         <body>
  10.           <h1>Z's Jewelers</h1>
  11.             <ul class="product_list">
  12.               <h2>Product List</h2>
  13.               <?php
  14.                 $products = array(
  15.                     "1" => array(
  16.                         "name" => $title,
  17.                         "id" => $productID,
  18.                         "price" => $price,
  19.                         "description" => $description,
  20.                         "image" => $image,
  21.                         "alt" => "atocha shipwreck emerald cross",
  22.                     ),
  23.                     "2" => array(
  24.                         "name" => $title,
  25.                         "id" => $productID,
  26.                         "price" => $price,
  27.                         "description" => $description,
  28.                         "image" => $image,                     
  29.                         "alt" => "Vinetian inspired emerald cross",
  30.                     ),
  31.                     "3" => array(
  32.                         "name" => $title,
  33.                         "id" => $productID,
  34.                         "price" => $price,
  35.                         "description" => $description,
  36.                         "image" => $image,
  37.                         "alt" => "Gold Ruby eyed snake bracelet",
  38.                     ),
  39.                     "4" => array(
  40.                         "name" => $title,
  41.                         "id" => $productID,
  42.                         "price" => $price,
  43.                         "description" => $description,
  44.                         "image" => $image,
  45.                         "alt" => "Diamond encrusted Hublot watch",
  46.                     ),
  47.                     "5" => array(
  48.                         "name" => $title,
  49.                         "id" => $productID,
  50.                         "price" => $price,
  51.                         "description" => $description,
  52.                         "image" => $image,
  53.                         "alt" => "Replica of the blue titanic heart charm and necklace",
  54.                     ),
  55.                     );
  56.                     $servername = "localhost:3306";
  57.                     $username = "root";
  58.                     $password = "";
  59.                     $dbname = "ourdatabase";
  60.                    
  61.                     $conn = mysqli_connect($servername, $username, $password, $dbname);
  62.  
  63.                     if (!$conn) {
  64.                         die("Connection failed: " . mysqli_connect_error());
  65.                     }
  66.                    
  67.                     $sql = "SELECT productID, title, description, image, stock, price FROM PRODUCT";
  68.                     $result = mysqli_query($conn, $sql);
  69.                     if (mysqli_num_rows($result) > 0) {
  70.                         while($row = mysqli_fetch_assoc($result)) {
  71.                             $productID = $row['productID'];
  72.                             $title= $row['title'];
  73.                             $description = $row['description'];
  74.                             $image = $row['image'];
  75.                             $stock = $row['stock'];
  76.                             $price = $row['price'];
  77.                         }
  78.                     }
  79.                
  80.                
  81.                     mysqli_close($conn);
  82.                 ?>
  83.                 <?php
  84.                     foreach($products as $product) {
  85.                     $href="shoppingcart.php?productid=" . $product['id']
  86.                         . "&productname=" . $product['name']
  87.                         . "&price=" . $product['price']
  88.                         . "&quantity=1";    
  89.                         echo '<li>
  90.                         <img src=" ' . $product['image'] . ' " alt=" ' .$product['alt'] . ' ">
  91.                         <div class="product_information">
  92.                             <h4>' . $product['name'] . '</h4>
  93.                             <span>' . $product['price'] . '</span>
  94.                         </div>
  95.                         <div class="product_description">
  96.                             <p>' . $product['description'] . '</p>
  97.                             <a href=" ' . $href .' "class="add_to_cart">Add to cart</a>
  98.                         </div>
  99.                         </li>';
  100.                     }
  101.                    
  102.                 ?>             
  103.                
  104.                
  105.  
  106.         </body>
  107.        
  108. </html>
Add Comment
Please, Sign In to add comment