forked from Abdullilah/eCommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems.php
195 lines (185 loc) · 11.4 KB
/
items.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
186
187
188
189
190
191
192
193
194
195
<?php
session_start();
$pageTitle = 'Items';
include "init.php";
?>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="layout/css/bootstrap.css"/>
<link rel="stylesheet" href="layout/css/font-awesome.min.css"/>
<link rel="stylesheet" href="layout/css/jquery-ui.css"/>
<link rel="stylesheet" href="layout/css/jquery.selectBoxIt.css"/>
<link rel="stylesheet" href="layout/css/frontEnd.css"/>
<title><?php getTitle();?></title>
</head>
<body>
<?php
if(isset($_GET['itemID']) && is_numeric($_GET['itemID'])){
$itemID = intval($_GET['itemID']);
} else{
$itemID = 0;
}
$stmt = $con->prepare("SELECT items.*,
categories.Name AS categoriesName,
users.Username AS userName
FROM items
INNER JOIN categories
ON categories.ID = items.Cat_ID
INNER JOIN users
ON users.UserID = items.Member_ID
WHERE ItemID=?
AND Approve=1");
$stmt->execute(array($itemID));
$count = $stmt->rowCount();
if($count > 0){
$item = $stmt->fetch();
?>
<h1 class="text-center"><?php echo $item["Name"]; ?></h1>
<div class="information">
<div class="container">
<div class="row">
<div class='col-sm-6 col-md-3'>
<div class='img-thumbnail'>
<img class='img-responsive' src='layout/images/image.png' alt='' />
</div>
</div>
<div class='col-sm-6 col-md-9 info-item'>
<h2><?php echo $item["Name"]; ?></h2>
<ul class="list-unstyled">
<li>
<i class="fa fa-book fa-fw"></i>
<span><?php echo $item["Description"]; ?></span>
</li>
<li>
<i class="fa fa-calendar fa-fw"></i>
<span>Added Date: <?php echo $item["Add_Date"]; ?></span>
</li>
<li>
<i class="fa fa-money fa-fw"></i>
<span>Price: $<?php echo $item["Price"]; ?></span>
</li>
<li>
<i class="fa fa-industry fa-fw"></i>
<span>Made in: <?php echo $item["Country_Name"]; ?></span>
</li>
<li>
<i class="fa fa-briefcase fa-fw"></i>
<span>Category: <a href="categories.php?catID=<?php echo $item['Cat_ID'];?>&catName=<?php echo $item["categoriesName"];?>"><?php echo $item["categoriesName"]; ?></a></span>
</li>
<li>
<i class="fa fa fa-user-o fa-fw"></i>
<span>Added By: <a href="#"><?php echo $item["userName"]; ?></a></span>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="dashedLine"></div>
<div class="addComm">
<div class="container">
<div class="row">
<div class='col-sm-6 col-md-3'></div>
<div class='col-sm-6 col-md-9'>
<h2>Add New Comment</h2>
<?php
if(isset($_SESSION['NormalUser'])){
?>
<form action="items.php?itemID=<?php echo $item["ItemID"];?>" method="POST">
<textarea name="comment" required></textarea>
<input class="btn btn-primary" type="submit" value="Add Comment">
</form>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
if(!empty($_POST["comment"])){
$comm = filter_var($_POST["comment"], FILTER_SANITIZE_STRING);
$user = $_SESSION['uID'];
$item = $item["ItemID"];
$stmt1 = $con->prepare("INSERT INTO comments
(C_Comment, C_Status, C_Date, item_ID, user_ID) VALUES
(:zcomm, 0, now(), :zitemID, :zuserID )");
$stmt1->execute(array(
'zcomm' => $comm,
'zitemID' => $item,
'zuserID' => $user
));
if($stmt1){
echo "<div class='alert alert-success'>Comment Added</div>";
}
} else{
echo "<div class='alert alert-danger'>Comment Must Not Be Empty </div>";
}
}
} else{
echo "To Add Comment <a href='login.php'>Log-in</a> or <a href='login.php'>Sign-in</a>";
}
?>
</div>
</div>
</div>
</div>
<div class="dashedLine"></div>
<div class="commItems">
<div class="container">
<h2 class="col-md-offset-2">Activited Comments</h2>
<?php
$stmt2 = $con->prepare("SELECT comments.*, users.Username AS Member
FROM comments
INNER JOIN users
ON users.UserID = comments.user_ID
WHERE item_ID=?
AND C_Status=1");
$stmt2->execute(array($itemID));
$count2 = $stmt2->rowCount();
if($count2 > 0){
$commnts = $stmt2->fetchAll();
foreach($commnts as $comm){
?>
<ul class="list-unstyled">
<li>
<div class="row">
<div class='col-sm-6 col-md-2'>
<img class='img-responsive img-thumbnail img-circle' src='layout/images/image.png' alt='' />
</div>
<div class='col-sm-6 col-md-10 comm-item'>
<!-- We can Add transparent in CSS to make it like a comments -->
<p class="nameCom"><?php echo $comm['Member']; ?></p>
<p><?php echo $comm['C_Comment']; ?></p>
</div>
</div>
</li>
</ul>
<?php
}
} else{
echo "<div class='alert alert-info'>
There is no Comments to Show ...
</div>";
}
?>
</div>
</div>
<?php
} else{
?>
<div class="container">
<h3 class="text-center alert alert-danger">There is no such an item or This Item Still Not Approved by the Admin</h3>
</div>
<?php
}
?>
<div class="footer">
</div>
<script src="layout/js/jquery-1.12.4.min.js"></script>
<script src="layout/js/jquery-ui.min.js"></script>
<script src="layout/js/bootstrap.min.js"></script>
<script src="layout/js/jquery.selectBoxIt.min.js"></script>
<script src="layout/js/backend.js"></script>
<script src="layout/js/frontend.js"></script>
<script src="layout/js/frontend1.js"></script>
</body>
</html>
<?php
ob_end_flush();
?>