This repository was archived by the owner on May 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem.php
More file actions
122 lines (119 loc) · 4.29 KB
/
Copy pathitem.php
File metadata and controls
122 lines (119 loc) · 4.29 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
<?php
/**
* Created by PhpStorm.
* User: barto
* Date: 23.01.18
* Time: 03:03
*/
session_start();
if (!isset($_GET['id'])) {
echo '
<script type="text/javascript">
window.location = "index.php"
</script>
';
die();
}
include('db-connection.php');
$productId = $_GET['id'];
if (!$dbconnection->connect_errno) {
$sql1 = "SELECT p.Date as Date, p.Value as Value, p.Name as Name, p.Id AS ProductId, u.Id as SellerId, p.Rating as Rating, p.Description as Description, p.Photo AS Photo, op.Id as OrderId, u.Username AS Username FROM `product` p LEFT JOIN `orderedproduct` op on op.ProductId = p.Id JOIN `user` u on p.sellerId=u.Id WHERE p.Id = '$productId';";
if ($result = $dbconnection->query($sql1)) {
$row = $result->fetch_assoc();
if ($row['Photo'] != null) {
$photo = $row['Photo'];
} else {
$photo = "img/defaultProductImg.png";
}
$sellerId = $row['SellerId'];
}
}
?>
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<link href="imports/bootstrap.min.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
<link href="css/item.css" rel="stylesheet">
<title><?php echo $row['Name'] ?> - UbijOkazje.pl</title>
<script src="imports/jquery-3.1.1.slim.min.js"></script>
<script src="imports/tether.min.js"></script>
<script src="imports/bootstrap.min.js"></script>
</head>
<body>
<div id="searchHeader">
<div style="float: left"><a href="index.php"><img src="img/logo.png" alt="logo" id="logoHeader"></a></div>
<?php
if (isset($_SESSION['user_login_status']) && $_SESSION['user_login_status'] == 1) {
echo '
<div id="userLinks" style="float: right; margin-left: 20px; margin-top: 35px;">
<p><a href="user.php">Moje konto</a></p>
<p><a href="logout.php">Wyloguj sie</a></p>
</div>
';
} else {
echo '
<div id="logLink" style="float: right; margin-left: 20px; margin-top: 35px;">
<p><a href="login.php">Zaloguj sie</a></p>
<p><a href="register.php">Zarejestruj sie</a></p>
</div>
';
}
?>
<div style="float: right; padding-top: 50px">
<form method="get" action="search.php">
<input name="query" id="searchBarHeader" type="text">
<button id="searchButtonHeader">Szukaj</button>
</form>
</div>
<div style="clear: both;"></div>
</div>
<table>
<tr><th colspan="3"><?php echo $row['Name'] ?></th></tr>
<tr>
<td id="productPhoto" rowspan="2"><img src="<?php echo $photo ?>"></td>
<td id="productDescription" rowspan="2"><?php echo $row['Description'] ?></td>
<td id="buyLink">
<?php
if ($row['OrderId'] == null) {
echo '<p>Stan: '.$row['Rating'].'</p>';
echo '<p>Cena: '.$row['Value'].'zl</p>';
echo '<p><a href="buy.php?id='.$row['ProductId'].'">Kup teraz</a></p>';
echo '<p><a href="addToDesired.php?id='.$row['ProductId'].'">Dodaj do obserwowanych</a></p>';
} else {
$sql2 = "SELECT op.dateOfOrder as dateOfOrder, op.isPaid as isPaid, u.username as username from `orderedproduct` op JOIN `user` u on u.Id = op.userId where op.Id = '".$row['OrderId']."';";
if ($result2 = $dbconnection->query($sql2)) {
$row2 = $result2->fetch_assoc();
echo "<p style='font-weight: bold'>Sprzedany: tak</p>";
echo "<p>Kupujacy: ".$row2['username']."</p>";
echo "<p>Sprzedany dnia: ".$row2['dateOfOrder']."</p>";
}
}
?>
</td>
</tr>
<tr>
<td id="sellerInfo">
<p>Sprzedajacy: <?php echo $row['Username'] ?></p>
<p>Data wystawienia: <?php echo $row['Date'] ?></p>
</td>
</tr>
<tr><th colspan="3">Otrzymane komentarze</th></tr>
<?php
if (!$dbconnection->connect_errno) {
$sql4 = "SELECT * FROM `comment` c JOIN `user` u on u.Id=c.AuthorId WHERE c.UserId = '$sellerId';";
if ($result = $dbconnection->query($sql4)) {
if ($result->num_rows == 0) {
echo "<tr><td colspan='3' class='comment'><p>Uzytkownik nie otrzymal jeszcze zadnych komentarzy.</p></td></tr>";
}
while($row = $result->fetch_assoc()) {
echo "<tr><td colspan='3' class='comment'>";
echo "<p>".$row['Text']."</p>";
echo "<p style='font-size: 14px;'>Wystawiono przez ".$row['Username'].", dnia ".$row['Date']."</p>";
echo "</td></tr>";
}
}
}
?>
</table>