-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle_category.php
164 lines (116 loc) · 3.17 KB
/
single_category.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
<?php
session_start();
ob_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>CATEGORY</title>
<style>
table,th, tr,td {border: #000 1px solid;}
img {width:150px; height:150px;}
</style>
</head>
<?php
require('header.php');
if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['username1']))
{
?>
<body>
<h1>Showing all for Category <?php echo $_GET["category"]; ?></h1>
<?php
$category_id =$_GET["id"];
if ($category_id <> "") {
$con = mysql_connect($servername,$username,$password) or die('Could not connect:'.mysql_error());
mysql_select_db($database, $con) or die('Could not select database.');
echo '<table class="table table-hover table-bordered">';
echo "<tr>";
echo "<th>Title</th>";
echo "<th>Price</th>";
echo "<th>Location</th>";
echo "<th>Region</th>";
echo "<th>SubCategory</th>";
echo "<th>Category</th>";
echo "<th>Description</th>";
echo "<th>Image1</th>";
echo "<th>Image2</th>";
echo "<th>Image3</th>";
echo "<th>Image4</th>";
// getting CATEGORY ID
$result0 = mysql_query("SELECT * FROM SubCategory WHERE Category_ID = " . $category_id);
while($row0 = mysql_fetch_array($result0)) {
$location_id = $row0[1];
$result = mysql_query("SELECT * FROM Posts WHERE Location_ID = " . $location_id);
echo "</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td><a href='single_post.php?id=". $row[0] . "'>" . $row[1] . "</a></td>";
//echo "<td>". $row[1] . "</td>";//
echo "<td>". $row[2] . "</td>";
// GETTING LOCATION AND REGION
$result2 = mysql_query("SELECT * FROM Location WHERE Location_ID = " . $row[12] ." LIMIT 1");
while($row2 = mysql_fetch_array($result2)) {
echo "<td>". $row2[0] . "</td>";
$region = $row2[2];
}
// GETTING REGION
$result21 = mysql_query("SELECT * FROM Region WHERE Region_ID = " . $region ." LIMIT 1");
while($row21 = mysql_fetch_array($result21)) {
echo "<td>". $row21[0] . "</td>";
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GETTING CATEGORY AND SUBCATEGORY
$result3 = mysql_query("SELECT * FROM SubCategory WHERE SubCategory_ID = " . $row[11] ." LIMIT 1");
while($row3 = mysql_fetch_array($result3)) {
echo "<td>". $row3[0] . "</td>";
$category = $row3[2];
}
// GETTING CATEGORY
$result31 = mysql_query("SELECT * FROM Category WHERE Category_ID = " . $category ." LIMIT 1");
while($row31 = mysql_fetch_array($result31)) {
echo "<td>". $row31[0] . "</td>";
}
echo "<td>". $row[3] . "</td>";
if ($row[7] <> ""){
echo "<td><img src='uploads/". $row[7] . "'/></td>";
}
else{
echo "<td></td>";
}
if ($row[8] <> ""){
echo "<td><img src='uploads/". $row[8] . "'/></td>";
}
else{
echo "<td></td>";
}
if ($row[9] <> ""){
echo "<td><img src='uploads/". $row[9] . "'/></td>";
}
else{
echo "<td></td>";
}
if ($row[10] <> ""){
echo "<td><img src='uploads/". $row[10] . "'/></td>";
}
else{
echo "<td></td>";
}
echo "</tr>";
}
}
echo '</table>';
echo "<br>";
echo "<br>";
mysql_close($con);
}
?>
</body>
<?php
}
else{
echo "Please, login to see this page.";
echo "<br>";
}
require('footer.php');
?>
</html>