-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
72 lines (53 loc) · 2.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
require 'vendor/autoload.php';
$client = new MongoDB\Client;
$ecommerce = $client->ecommerce;
$products = $ecommerce->products;
$allProducts = $products->find([]);
?>
<?php session_start(); ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>E-commerce</title>
</head>
<style>
</style>
<body>
<?php
if (isset($_SESSION['email'])) {
include "navigationwhenuserloggedin.php";
$username = $_SESSION['name'];
} else {
include "navigationwhenusernotloggedin.php";
}
?>
<div class="container">
<div class="row">
<?php
foreach($allProducts as $myProduct){
$product_id = $myProduct->product_id;
$name = $myProduct->name;
$description = $myProduct->description;
$price = $myProduct->price;
$stock = $myProduct->stock;
$image = $myProduct->image;
?>
<div class="card my-3 mx-3 border border-dark" style="width: 13rem;">
<img src="images/<?php echo $image; ?>" alt="Card image cap" height="170px" class="mt-3">
<div class="card-body">
<h5 class="card-title"><?php echo $name; ?></h5>
<p class="card-text">$<?php echo $price; ?></p>
<p class="class-text"><small><?php echo $stock; ?> left in stock</small></p>
</div>
<a class="btn btn-dark btn-block mb-4 mx-3 " href='product.php?product_id=<?php echo $product_id; ?>'>View Product</a>
</div>
<?php } ?>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
</body>
</html>