-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.php
More file actions
222 lines (195 loc) · 9.21 KB
/
Product.php
File metadata and controls
222 lines (195 loc) · 9.21 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
session_start();
if(!isset($_SESSION['user']))
header("location: index.php?Message=Login To Continue");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Books">
<title>Online Bookstore</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/my.css" rel="stylesheet">
<style>
#books {margin-bottom:50px;}
@media only screen and (width: 767px) { body{margin-top:150px;}}
#books .row{margin-top:20px;margin-bottom:10px;font-weight:800;}
@media only screen and (max-width: 760px) { #books .row{margin-top:10px;}}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php" style="margin: -7px 0px -22px -35px;"><img alt="Brand" src="img/logo.png" style="width: 127px;margin: -13px;"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<?php
if(isset($_SESSION['user']))
{
echo'
<li><a href="index.php" class="btn btn-lg">Home</a></li>
<li><a href="cart.php" class="btn btn-lg">Cart</a></li>
<li> <a href="history.php" class="btn btn-lg"> Order history </a> </li>;
<li> <a href="destroy.php" class="btn btn-lg"> LogOut </a> </li> ';
}
?>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div id="top" >
<div id="searchbox" class="container-fluid" style="width:112%;margin-left:-6%;margin-right:-6%;">
<div>
<form role="search" action="Result.php" method="post">
<input type="text" name="keyword" class="form-control" placeholder="Search for a Book , Author Or Category" style="width:80%;margin:20px 10% 20px 10%;">
</form>
</div>
</div>
<?php
include "dbconnect.php";
if(isset($_GET['value']))
{
$_SESSION['category']=$_GET['value'];
}
$category=$_SESSION['category'];
if(isset($_POST['sort']))
{
if($_POST['sort']=="price")
{ $query = "SELECT * FROM products WHERE Category='$category' ORDER BY Price";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
?>
<script type="text/javascript">
document.getElementById('select').Selected=$_POST['sort'];
</script>
<?php
}
else
if($_POST['sort']=="priceh")
{ $query = "SELECT * FROM products WHERE Category='$category' ORDER BY Price DESC";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
}
else
{ $query = "SELECT * FROM products WHERE Category='$category' and Available > 0";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
$i=0;
echo '<div class="container-fluid" id="books">
<div class="row">
<div class="col-xs-12 text-center" id="heading">
<center><h2 style="color:#390858;text-transform:uppercase;margin-bottom:0px; border-bottom: 2px solid black;
width: fit-content;"> '. $category .' STORE </h2></center>
</div>
</div>
<div class="container fluid">
<div class="row">
<div class="col-sm-5 col-sm-offset-6 col-md-5 col-md-offset-7 col-lg-4 col-lg-offset-8">
<form action="';echo $_SERVER['PHP_SELF'];echo'" method="post" class="pull-right">
<label for="sort" style="font-size: 15px;">Sort by  :  </label>
<select name="sort" id="select" onchange="form.submit()">
<option value="default" name="default" selected="selected">Select</option>
<option value="price" name="price">Low To High Price </option>
<option value="priceh" name="priceh">Highest To Lowest Price </option>
</select>
</form>
</div>
</div>
</div>';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$path="img/books/".$row['PID'].".jpg";
$description="description.php?ID=".$row["PID"];
if($i%4==0)
echo '<div class="row">';
echo'
<a href="'.$description.'">
<div class="col-sm-6 col-md-3 col-lg-3 text-center">
<div class="book-block" style="border :3px solid #DEEAEE; color: black; font-size: 16px; font-family: -webkit-pictograph;">
<img class="book block-center img-responsive" src="'.$path.'">
<hr>
' . $row["Title"] . '<br>
<span style="font-family: sans-serif; color: #081e86;">Rs. ' . $row["Price"] .'  </span>
';
if($row["Available"]<5)
{
echo ' <p style="color:red;"> Hurry!! Only '. $row["Available"] .' left in stock.</p>';
}
echo '
</div>
</div>
</a> ';
$i++;
if($i%4==0)
echo '</div>';
}
}
echo '</div>';
?>
<footer style=" background:#9794af;bottom:0px;clear: both;position: relative;height: 300px;margin-top: -200px;">
<div class="container-fluid">
<div class="row">
<div class="col-sm-1 col-md-1 col-lg-1">
</div>
<div class="col-sm-7 col-md-5 col-lg-5">
<div class="row text-center">
<h2>Get In Touch!</h2>
<hr class="primary">
<p>Still Confused? Give us a call or send us an email and we will get back to you as soon as possible!</p>
</div>
<div class="row">
<div class="col-md-6 text-center">
<span class="glyphicon glyphicon-earphone"></span>
<p>123-456-6789</p>
</div>
<div class="col-md-6 text-center">
<span class="glyphicon glyphicon-envelope"></span>
<p>[email protected]</p>
</div>
</div>
</div>
<div class="hidden-sm-down col-md-2 col-lg-2">
</div>
<div class="col-sm-4 col-md-3 col-lg-3 text-center">
<h2 style="color:#390858;">Follow Us At</h2>
<div>
<img title="Twitter" alt="Twitter" src="img/social/twitter.png" width="35" height="35" />
<img title="LinkedIn" alt="LinkedIn" src="img/social/linkedin.png" width="35" height="35" />
<img title="Facebook" alt="Facebook" src="img/social/facebook.png" width="35" height="35" />
<img title="google+" alt="google+" src="img/social/google.jpg" width="35" height="35" />
<img title="Pinterest" alt="Pinterest" src="img/social/pinterest.jpg" width="35" height="35" />
</div>
</div>
</div>
</div>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<!--
<script>
$('#my_select').change(function() {
// assign the value to a variable, so you can test to see if it is working
var selectVal = $('#my_select :selected').val();
alert(selectVal);
});
</script>
-->