-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
82 lines (68 loc) · 2.53 KB
/
index.php
File metadata and controls
82 lines (68 loc) · 2.53 KB
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
73
74
75
76
77
78
79
80
81
82
<?php
// Starts the user session
session_start();
//Gets credentials and connects to db
include "data-con.php";
// Selects all rows from the "products" table
$sql = "SELECT * FROM products ORDER BY RAND()";
$results =$conn->query($sql);
if ($results) {
$msg = "It works!";
} else {
$msg = "It doesn't work :( " . $conn->error;
}
// Selects all rows from the "categories" table
$sql2 = "SELECT * FROM product_categories";
$results2 =$conn->query($sql2);
if ($results2) {
$msg = "It works!";
} else {
$msg = "It doesn't work :( " . $conn->error;
}
// This page's header text
$headerText = "<h1 class=\"display-1\">Planayana</h1><h4 class=\"tag-line\">Bringing textures into your classroom</h1>";
// Close db connection
$conn->close();
?>
<!DOCTYPE html>
<html>
<!-- Gets the header -->
<?php include("header.php"); ?>
<div class="container">
<div class="row">
<div class="col-12">
<!-- category display -->
<h3 class="display-4 categories">Categories</h3>
<div class="card-deck">
<!-- loops over the product categories -->
<?php while ($row2 = $results2->fetch_assoc()) {?>
<div class="card no-flex" style="width: 18rem;">
<img class="card-img-top" src="<?php echo $row2["category_image"] ?>" alt="Card image cap" >
<div class="card-body centre">
<a href="categories.php?id=<?php echo $row2["id"];?>" class="button "><?php echo $row2["name"] ?></a>
</div>
</div>
<?php } ?>
</div>
<!-- masonary style layout for products -->
<h3 class="display-4 all-products">All Products</h3>
<div class="card-columns">
<!-- Runs a while loop to iterate over all the products -->
<?php while ($row = $results->fetch_assoc()) {?>
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="<?php echo $row["image_url"] ?>" alt="Card image cap">
<div class="card-body">
<h5 class="card-title"><?php echo $row["name"] ?></h5>
<h6 class="card-title">$<?php echo $row["price"] ?></h6>
<a href="product.php?id=<?php echo $row["id"]?>" class="button">More Info</a>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
<!-- Gets the footer -->
<?php include("footer.php") ?>
</body>
</html>