-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathperfumes.php
51 lines (46 loc) · 1.62 KB
/
perfumes.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
<?php
include_once('commonPHP/headerNav.php');
outputHTMLtags();
outputHeaderNav("Perfumes");
?>
<!-- website window resolution 1278 x 1940.58 -->
<?php
//Include libraries
require __DIR__ . '/vendor/autoload.php';
//Create instance of MongoDB client
$mongoClient = (new MongoDB\Client);
//Select a database
$db = $mongoClient->perfumefest;
// creating a cursor of all product's data
$cursor = $db->Products->find();
//outputting a grid wrapper and a wrapper for all products
echo '<div id="sort-products">
<div id="sort-options">
<select id="select-options" size="1" name="pet" onchange="sortItems()">
<option value="noSort">None</option>
<option value="PriceAsc">Price-[low-high]</option>
<option value="PriceDec">Price-[high-low]</option>
<option value="AtoZ">Order from[A-Z]</option>
</select>
</div>
<button onclick="sortItems()">Sort</button>
</div>';
echo '<div class="products-wrapper">';
echo '<div class="gridwrapper">';
// looping through arrays of data from mongodb and outputing specific product values
foreach ($cursor as $product) {
echo '<div class="perfume-data">';
echo ' <dive class="item-msg"></dive>';
echo ' <div class="item-picture"><img class="item-img" src="./' . $product['img_url'] . '" alt=""></div>';
echo ' <div class="item-name">' . $product['Name'] . '</div>';
echo ' <div class="item-size">' . $product['size'] . '</div>';
echo ' <div class="item-price">£' . $product['Price'] . '</div>';
echo ' <button class="addbtn" >Add to Cart</button>
</div>';
}
echo '</div>
</div>';
?>
<?php
outputFooter();
?>