-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.php
185 lines (179 loc) · 7.38 KB
/
product.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!-- PRODUCT PAGE-->
<!-- ADAM POHL -->
<!-- WRITTEN FOR CS3500 -->
<?php
include 'specifications.inc.php';
include 'config.inc.php';
//Create a session if one was not already created
include 'create_session.inc.php';
//Set values in the data base entry for session specefic data
include 'append_user_session_data.inc.php';
// Connect to database
try{
$pdo = new PDO(DBCONNSTRING, DBUSER, DBPASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e){
die($e -> getMessage());
}
if(count($_GET) >= 1){
$id = $_GET["productID"];
}
else{
echo "NO PRODUCT ID PASSED";
// Currently process just dies if not id is passed
// Consider rerouting to 404 page instead
die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Atlas Corporation</title>
<!-- Link to Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/navbar.css">
<link rel="stylesheet" type="text/css" href="css/product.css">
<!-- Google fonts link -->
<link href="https://fonts.googleapis.com/css?family=Nanum+Gothic&display=swap" rel="stylesheet">
<!-- Font Awesome icon link -->
<script src="https://kit.fontawesome.com/2a7a1d5a6b.js" crossorigin="anonymous"></script>
<!-- Scripts to run carousel -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="javascript/product.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<nav class="navbar navbar-expand-sm navbar-dark fixed-top" id="navigation">
<!-- Brand/Logo -->
<a class="navbar-brand" href="index.php">
<img src="images/Company-Logo.png" alt="Atlas Corporation" title="Atlas Corporation">
</a>
<!-- Pages -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About Us</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="catalog.php">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="cart.php">Cart</a>
</li>
<li class="nav-item">
<a class="nav-link" href="weather.php">Weather</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact_us.html">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="log_in.html">Log In</a>
</li>
</ul>
</nav>
</div> <!-- End Navbar -->
<div class="row">
<!-- Product Info -->
<div class="col-md-6">
<div class="description">
<!-- Motto for laptop -->
<div class="text-left catch_phrase">
</div>
</div>
</div>
<div class="col-md-6">
<!-- Class contains product carousel -->
<!-- Carousel scripts found on W3Schools -->
<div id="demo" class="carousel slide" data-ride="carousel">
<!-- Each item relates to a picture in the carousel -->
<?php
// PHP to control Carousel
// Make an output variable to store html data
$output = '';
$output .= '<div class="carousel-inner">';
// For each image append to output variable
for($i = 1; $i <= 3; $i++){
$output .= '<div class="carousel-item';
// For first image set class to active
if($i == 1){
$output .= ' active">';
}
else{
$output .= '">';
}
$output .= '<img src=images/products/' . $id . '-car' . $i . '.jpg width="1100" height="500">';
$output .='</div>';
}
$output .= '</div>';
echo $output;
?>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<i class="fas fa-arrow-left"></i>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<i class="fas fa-arrow-right"></i>
</a>
</div> <!-- End Carousel-->
</div> <!-- End Column -->
</div> <!-- End Row -->
<div class="row">
<!-- Laptop specs for actual laptop found on Newegg -->
<ul class="jumbotron">
<li class="specs">PRODUCT SPECIFICATIONS</li>
<?php
// Loop through all values in $specs[$id] to get product specifications
foreach($specs[$id] as $val){
echo '<li>' . $val . '</li>';
}
?>
</ul>
</div>
<div class="row info_section">
<div class="col-md-2">
<!-- Left images -->
<?php
// Rewrote image printing using php loops
$output = "";
for($i = 1; $i <= 3; $i++){
$output .= '<img class="pic" src="images/products/' .$id . '-left' . $i . '.jpg" alt="">';
}
echo $output;
?>
</div>
<div class="col-md-8">
<!-- Product Descrption -->
<?php
$sql = "SELECT * FROM products WHERE ID='" . $id . "'";
$product = $pdo -> query($sql);
$row = $product -> fetch();
$description = '<p class="desc">' . $row["Description"] . "</p>";
echo $description;
$button = '<button type="button" class="btn btn-danger btn-lg"><a href="catalog.php?cart=' . $id . '">Add to Cart</a></button>';
echo $button;
?>
</div>
<div class="col-md-2">
<!-- Right Images -->
<?php
$output = "";
for($i = 1; $i <= 3; $i++){
$output .= '<img class="pic" src="images/products/' .$id . '-right' . $i . '.jpg" alt="">';
}
echo $output;
?>
</div>
</div>
</div>
<footer>
<p>© Atlas Corporation 2020</p>
</footer>
</body>
</html>