-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_list.php
174 lines (148 loc) · 5.17 KB
/
product_list.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
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
// Run a select query to get my letest 6 items
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
$dynamicList_pc = "";
$dynamicList_xbox = "";
$sql_pc = "SELECT * FROM products WHERE subcategory='PC' ORDER BY date_added DESC LIMIT 20";
$sql_query_pc = $DBH->prepare($sql_pc);
$sql_query_pc->execute();
$results_pc = $sql_query_pc->fetchAll(PDO::FETCH_ASSOC); // fetches everything in products
if ($results_pc > 0) {
foreach($results_pc as $row){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList_pc .= '
<div class="large-4 small-6 columns">
<img class="framed_picture" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" >
<div class="panel">
<h5>'. $product_name .'</h5>
<h6 class="subheader">' . $price . '€</h6>
<a class="button success tiny" href="product.php?id=' . $id . '">View Product Details</a>
</div>
</div>';
}
} else {
$dynamicList_pc = "We have no products listed in our store yet";
}
$dynamicList_ps3 = "";
$sql_ps3 = "SELECT * FROM products WHERE subcategory='PS3' ORDER BY date_added DESC LIMIT 20";
$sql_query_ps3 = $DBH->prepare($sql_ps3);
$sql_query_ps3->execute();
$resulsts_ps3 = $sql_query_ps3->fetchAll(PDO::FETCH_ASSOC); // fetches everything in products
if ($resulsts_ps3 > 0) {
foreach($resulsts_ps3 as $row){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList_ps3 .= '
<div class="large-4 small-6 columns">
<img class="framed_picture" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" >
<div class="panel">
<h5>'. $product_name .'</h5>
<h6 class="subheader">' . $price . '€</h6>
<a class="button success tiny" href="product.php?id=' . $id . '">View Product Details</a>
</div>
</div>';
}
} else {
$dynamicList_ps3 = "We have no products listed in our store yet";
}
$dynamicList_xbox360 = "";
$sql_xbox360 = "SELECT * FROM products WHERE subcategory='Xbox360' ORDER BY date_added DESC LIMIT 20";
$sql_query_xbox360 = $DBH->prepare($sql_xbox360);
$sql_query_xbox360 ->execute();
$resulsts_xbox360 = $sql_query_xbox360->fetchAll(PDO::FETCH_ASSOC); // fetches everything in products
if ($resulsts_xbox360 > 0) {
foreach($resulsts_xbox360 as $row){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList_xbox360 .= '
<div class="large-4 small-6 columns">
<img class="framed_picture" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" >
<div class="panel">
<h5>'. $product_name .'</h5>
<h6 class="subheader">' . $price . '€</h6>
<a class="button success tiny" href="product.php?id=' . $id . '">View Product Details</a>
</div>
</div>';
}
} else {
$dynamicList_xbox360 = "We have no products listed in our store yet";
}
?>
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ali's Game Store | Welcome</title>
<link rel="stylesheet" href="css/foundation.css" />
<script src="js/modernizr.js"></script>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body>
<div class="row">
<div class="large-12 columns">
<?php include_once("template_header.php");?>
<div class="row">
<!-- Side Bar -->
<div class="large-4 small-12 columns">
<div class="hide-for-small panel">
<h3>Products page</h3>
<h5 class="subheader">
Here you can see all the available products we have to offer.</h5>
</div>
<?php
if ( isset($_SESSION['email']) || isset($_SESSION['manager'])){
echo "<a href=\"http://users.metropolia.fi/~aliab/webstore/cart.php\">
<div class=\"panel callout radius\">
<h6>Your Cart</h6>
</div></a>";
}
?>
</div><!-- End Side Bar -->
<!-- Thumbnails -->
<div class="large-8 columns">
<div class="row">
<?php if(isset($_GET['pc']))
{
echo "<h3>PC products list:</h3>";
echo $dynamicList_pc;
}
if(isset($_GET['xbox360']))
{
echo "<h3 class=\"subheader\">Xbox360 products list:</h3>";
echo $dynamicList_xbox360;
}
if(isset($_GET['ps3']))
{
echo "<h3>PS3 products list:</h3>";
echo $dynamicList_ps3;
}
?>
</div>
</div>
</div>
<?php include_once("template_footer.php");?>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/foundation.min.js"></script>
<script>
$(document).foundation();
var doc = document.documentElement;
doc.setAttribute('data-useragent', navigator.userAgent);
</script>
</body>
</html>