-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcategory.php
76 lines (72 loc) · 2.8 KB
/
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
<?php
include 'template/header.php';
include 'function/db.php';
if(isset($_GET['category'])){
$category_id = $_GET['category'];
if($category_id == 'all'){
$query = "SELECT * FROM item, category WHERE category.category_id = item.category_id AND status = 1 ORDER BY item.item_id DESC";
}else{
$query = "SELECT * FROM item, category WHERE category.category_id = '$category_id' AND item.category_id = '$category_id' AND status = 1 ORDER BY item.item_id DESC";
}
$result = mysql_query($query) or die(mysql_error());
}
if(isset($_GET['archive'])){
$archive_id = $_GET['archive'];
if($archive_id == 'all'){
$query = "SELECT * FROM item, category WHERE category.category_id = item.category_id AND status = 0 ORDER BY item.item_id DESC";
}else{
$query = "SELECT * FROM item, category WHERE category.category_id = '$archive_id' AND item.category_id = '$archive_id' AND status = 0 ORDER BY item.item_id DESC";
}
$result = mysql_query($query) or die(mysql_error());
}
if(!isset($_GET['archive']) && !isset($_GET['category'])){
header('Location: index.php');
exit();
}
?>
<h1>
<?php
if(!empty($category_id)){
$queryCat = "SELECT * FROM category WHERE category_id = '$category_id' LIMIT 1";
$resultCat = mysql_query($queryCat) or die(mysql_error());
if(mysql_num_rows($resultCat)!=0){
$rowCat = mysql_fetch_array($resultCat);
echo "Category: ".$rowCat['category_name'];
}else{
echo "Category: ALL";
}
}
if(!empty($archive_id)){
$queryCat = "SELECT * FROM category WHERE category_id = '$archive_id' LIMIT 1";
$resultCat = mysql_query($queryCat) or die(mysql_error());
if(mysql_num_rows($resultCat)!=0){
$rowCat = mysql_fetch_array($resultCat);
echo "Archive: ".$rowCat['category_name'];
}else{
echo "Archive: ALL";
}
}
?>
</h1>
<?php
if(mysql_num_rows($result) == 0){
echo "<p>No auction item available in this category</p>";
}else{
while($row = mysql_fetch_array($result))
{
echo "<div class='item'>";
echo "<div class='itemImage'><a href='item.php?itemid=" . $row['item_id'] . "'><img src='" . $row['photo'] . "' alt='" . $row['itemname'] . "'/></a></div>";
echo "<p><span class='itemname'>Name:</span><a href='item.php?itemid=" . $row['item_id'] . "'>" . $row['itemname'] . "</a></p>";
echo "<p><span>End time:</span> " . $row['endtime'] . "</p>";
if(!empty($category_id)){
echo "<p><span class='itemcategory'>Category:</span><a href='category.php?category=" . $row['category_id'] . "'>" . $row['category_name'] . "</a></p>";
}
if(!empty($archive_id)){
echo "<p><span class='itemcategory'>Category:</span><a href='category.php?archive=" . $row['category_id'] . "'>" . $row['category_name'] . "</a></p>";
}
echo "</div>";
}
}
?>
<script type="text/javascript" src="asset/equalHeightCol.js"></script>
<?php include 'template/footer.php'; ?>