Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1. <?php
  2.  
  3. //connect to database
  4. include('dataBaseConnection.inc');
  5. include('linkcss.php');
  6. include('Product.php');
  7. session_start();
  8. $product = array();
  9.  
  10. $product = unserialize($_SESSION['product']);
  11. var_dump($product);
  12. foreach($product as $key => $value){
  13.     $id = $value->getId();
  14.     $name = $value->getName();
  15.     $color = $value->getColor();
  16.     $size = $value->getSize();
  17.     $qty = $value->getQuantity();
  18.  
  19.     $inventory_res = "SELECT * FROM inventory WHERE item_id='".$id."'";
  20.     $inventory_sql = $conn -> query($inventory_res) or die($conn->error);
  21.  
  22.     if($inventory_sql->num_rows >= 1){
  23.     while($inventory_check = $inventory_sql->fetch_array()) {
  24.         $inv_item = $inventory_check['item_id'];
  25.         $inv_color = $inventory_check['item_color'];
  26.         $inv_size = $inventory_check['item_size'];
  27.         $inv_qty = $inventory_check['inventory'];
  28.  
  29.             $newqty = $inv_qty - $qty;
  30.             $resStatement = "UPDATE inventory SET inventory ='".$newqty."' WHERE item_id ='".$id."' AND item_color ='".$color."' AND item_size ='".$size."'  ";
  31.             $sqlStatement = $conn->query($resStatement) or die("Can't update record");
  32.  
  33.     }
  34.     $inventory_sql->free();
  35.  
  36.     }
  37.     else
  38.         echo "<h1>PROBELM</h1>";
  39.  
  40. }
  41.  
  42. $conn->close();
  43.  
  44. ?>
  45.  
  46. <html class="p-3 mb-2 bg-info text-white">
  47. <head>
  48.  
  49.     <meta charset="UTF-8">
  50.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  51.     <title>Show Cart</title>
  52.     <link rel = "icon" type = "img/png" href = "XYZlogo.png">
  53. </head>
  54.  
  55. <body class="p-3 mb-2 bg-info text-white">
  56.  
  57. <div id="body">
  58.     <header class="row">
  59.         <img src="XYZlogo.png" alt="XYZ logo Shopping Cart" width="10%" height="17%" >
  60.  
  61.         <h1><b>XYZ Store Website</b></h1>
  62.  
  63.     </header>
  64.  
  65.  
  66.     <div class="row">
  67.         <nav class="col-lg-2" class="col-sm-12">
  68.             <ul><a href="index.html"><li>Home</li></a>
  69.                 <a href="contact.html"><li>Contact Us</li></a>
  70.                 <a href="aboutUs.html"><li>About Us</li></a>
  71.                 <a href="seestore.php"><li>Store</li></a>
  72.             </ul>
  73.         </nav>
  74.  
  75.         <main class="col-lg-9" class="col-sm-12">
  76.         <h2>Thank you for your purchase!</h2>
  77.  
  78.  
  79.             <a href="index.html">Back to Website</a><br>
  80.  
  81.         </main>
  82.     </div>
  83.     <p></p>
  84.     <footer class="col-lg-12">
  85.         <p><i>
  86.                 XYZ Corporations©<br>
  87.                 Thomas Deschenes<br>
  88.                 thomd00@outlook.com
  89.  
  90.             </i></p>
  91.  
  92.     </footer>
  93. </div>
  94.  
  95. </body>
  96.  
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement