Skip to content

Commit

Permalink
connected the shop page to the database -fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
mennamamdouh committed May 3, 2023
1 parent 4632e52 commit d81a08b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ecommerce-website/shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

session_start();

if(isset($_SESSION['user_id'])){
$user_id = $_SESSION['user_id'];
if(isset($_SESSION['CustomerID'])){
$user_id = $_SESSION['CustomerID'];
}else{
$user_id = '';
};
Expand Down Expand Up @@ -40,26 +40,26 @@
<div class="box-container">

<?php
$select_products = $conn->prepare("SELECT * FROM `products`");
$select_products = $conn->prepare("SELECT * FROM Products");
$select_products->execute();
if($select_products->rowCount() > 0){
while($fetch_product = $select_products->fetch(PDO::FETCH_ASSOC)){
?>
<form action="" method="post" class="box">
<input type="hidden" name="pid" value="<?= $fetch_product['id']; ?>">
<input type="hidden" name="name" value="<?= $fetch_product['name']; ?>">
<input type="hidden" name="pid" value="<?= $fetch_product['productid']; ?>">
<input type="hidden" name="name" value="<?= $fetch_product['productname']; ?>">
<input type="hidden" name="price" value="<?= $fetch_product['price']; ?>">
<input type="hidden" name="image" value="<?= $fetch_product['image_01']; ?>">
<input type="hidden" name="image" value="<?= $fetch_product['image_1']; ?>">
<button class="fas fa-heart" type="submit" name="add_to_wishlist"></button>
<a href="quick_view.php?pid=<?= $fetch_product['id']; ?>" class="fas fa-eye"></a>
<img src="uploaded_img/<?= $fetch_product['image_01']; ?>" alt="">
<div class="name"><?= $fetch_product['name']; ?></div>
<a href="quick_view.php?pid=<?= $fetch_product['productid']; ?>" class="fas fa-eye"></a>
<img src="uploaded_img/<?= $fetch_product['image_1']; ?>" alt="">
<div class="name"><?= $fetch_product['productname']; ?></div>
<div class="flex">
<div class="price"><span>$</span><?= $fetch_product['price']; ?><span>/-</span></div>
<input type="number" name="qty" class="qty" min="1" max="<?php echo $fetch_product['InStock']; ?>" onkeypress="if(this.value.length == 2) return false;" value="1">
<input type="number" name="qty" class="qty" min="1" max="<?php echo $fetch_product['itemsinstock']; ?>" onkeypress="if(this.value.length == 2) return false;" value="1">
</div>
<?php
if($fetch_product['InStock']>0)
if($fetch_product['itemsinstock']>0)
{ ?>
<input type="submit" value="add to cart" class="btn" name="add_to_cart">
<?php
Expand All @@ -74,7 +74,7 @@
<?php
}
}else{
echo '<p class="empty">no products found!</p>';
echo '<p class="empty">No products found!</p>';
}
?>

Expand Down

0 comments on commit d81a08b

Please sign in to comment.