-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthor.php
More file actions
162 lines (150 loc) · 6.88 KB
/
Author.php
File metadata and controls
162 lines (150 loc) · 6.88 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
<?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">
<meta name="author" content="Shivangi Gupta">
<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: 768px) { body{margin-top:150px;}}
#books .row{margin-top:30px;margin-bottom:30px;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"><img alt="Brand" src="img/logo.jpg" style="width: 118px;margin-top: -7px;margin-left: -10px;"></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="cart.php" class="btn btn-md"><span class="glyphicon glyphicon-shopping-cart">Cart</span></a></li>
<li><a href="destroy.php" class="btn btn-md"> <span class="glyphicon glyphicon-log-out">LogOut</span></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" class="form-control" name="keyword" 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['author']=$_GET['value'];
}
$author=$_SESSION['author'];
if(isset($_POST['sort']))
{
if($_POST['sort']=="price")
{ $query = "SELECT * FROM products WHERE Author='$author' ORDER BY Price";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
else
if($_POST['sort']=="priceh")
{ $query = "SELECT * FROM products WHERE Author='$author' ORDER BY Price DESC";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
else
if($_POST['sort']=="discount")
{ $query = "SELECT * FROM products WHERE Author='$author' ORDER BY Discount DESC";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
else
if($_POST['sort']=="discountl")
{ $query = "SELECT * FROM products WHERE Author='$author' ORDER BY Discount";
$result = mysqli_query ($con,$query)or die(mysqli_error($con));
}
}
else
$query = "SELECT * FROM products WHERE Author='$author'";
$result = mysqli_query ($con,$query)or die(mysql_error());
$i=0;
echo '<div class="container-fluid" id="books">
<div class="row">
<div class="col-xs-12 text-center" id="heading">
<h2 style="color:#D67B22;text-transform:uppercase;margin-bottom:0px;"> '. $author .' STORE </h2>
</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">Sort by  :  </label>
<select name="sort" 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>
<option value="discountl" name="discountl">Low To High Discount </option>
<option value="discount" name="discount">Highest To Lowest Discount</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;">
<img class="book block-center img-responsive" src="'.$path.'">
<hr>
' . $row["Title"] . '<br>
' . $row["Price"] .'  
<span style="text-decoration:line-through;color:#828282;"> ' . $row["MRP"] .' </span>
<span class="label label-warning">'. $row["Discount"] .'%</span>
</div>
</div>
</a> ';
$i++;
if($i%4==0)
echo '</div>';
}
}
echo '</div>';
?>
<!-- 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>