forked from lorinn/B3-First_Year_TeamProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buying.php
151 lines (123 loc) · 4.76 KB
/
buying.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
<?php
include('header_menuleft.php');
include('config.php');
include("pagination.php");
include_once("functions.php");
$user_id = $_SESSION['user_id'];
?>
<div class="buying_box_body">
<h2>Buying items</h2>
<?php
$p = new pagination();
$conn = mysql_query("SELECT * FROM items WHERE `status` = 1 AND `type` = 1");
$j = 0;
while($temp = mysql_fetch_assoc($conn)){
$j++;
}
if(!isset($_GET['page'])){ $page = 1; } else { $page = escape_value($_GET['page']); }
$arr = $p->calculate_pages($j, 12, $page); //pagination
$pagehtml = " <br clear=all><p style='font-size:14px !important; display:block;'>Pages:</p> <ul class='pagination'>";
if($arr['current'] > 1){
$pagehtml .= "<li><a href=?page={$arr['previous']}><<</a></li>";
}
$max_number = $arr['current'] + 6;
foreach($arr['pages'] as $pageid){
if($arr['current'] == $pageid){
$pagehtml .= "<li>{$pageid}</li>";
} else {
if($pageid <= $max_number AND $pageid > $arr['current'] ){
$pagehtml .= "<li><a href=?page={$pageid}>{$pageid}</a></li>";
}
}
}
if($arr['current']+2 <= (int)$arr['last']){
$arrows = $arr['current']+5;
$pagehtml .= "<li><a href=?page={$arrows}>>></a></li>";
}
$pagehtml .= "</ul><br/>";
$i = 0;
$query3 = mysql_query("SELECT * FROM items WHERE `status` = 1 AND `type` = 1 ORDER BY `item_id` DESC {$arr['limit']}");
$endline_count=0;
while ($row = mysql_fetch_assoc($query3))
{
$item_id = $row['item_id'];
$user_id = $row['user_id'];
$creation_date = $row['creation_date'];
$expiration_date = $row['expiration_date'];
$status = $row['status'];
$type = $row['type'];
$name = stripslashes($row['name']);
$category_id = $row['category_id'];
$views = $row['views'];
$picture = $row['picture'];
if($picture == NULL)
$picture='images/no_image.jpg';
else
$picture="uploads/".$picture;
$query4 = mysql_query("SELECT * FROM users WHERE user_id = '$user_id' ");
while ($row = mysql_fetch_assoc($query4))
{
$owner_name = $row['name'];
$owner_last_name = $row['last_name'];
$query5 = mysql_query("SELECT * FROM categories WHERE category_id = '$category_id' ");
while ($row = mysql_fetch_assoc($query5))
{
$category_name = $row['category_name'];
if($status == 1 && $type == 1 && $endline_count < 16)
{
$endline_count++;
echo "
<div class='prod_box'>
<div class='top_prod_box'></div>
<div class='center_prod_box blocks'>
<div class='product_title'><a href='item_page.php?id=".$item_id."'>".$name."</a></div>
<div class='product_img'><a href='item_page.php?id=".$item_id."'><img border='0' height='94' width='94' src='".$picture."'></a></div>
<div class='creation_date'>Created: <span class='creation'>".$creation_date ."</span></div>
<div class='expiration_date'>Expires: <span class='expiration'>".$expiration_date ."</span></div>
<div class='created_by'>By: <span class='user'>".$owner_name." ".$owner_last_name."</span></div>
<div class='views_product'>Views: <span class='views'>".$views ."</span></div>
<div class='category_name'>Category: <span class='category'>".$category_name ."</span></div>
</div>
<div class='bottom_prod_box'></div>
</div>
";
}
}
}
}
if($endline_count != 0) echo $pagehtml;
?>
</div>
<script>
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$('.blocks').each(function() {
$el = $(this);
topPostion = $el.position().top;
if (currentRowStart != topPostion) {
// we just came to a new row. Set all the heights on the completed row
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
// set the variables for the new row
rowDivs.length = 0; // empty the array
currentRowStart = topPostion;
currentTallest = $el.height();
rowDivs.push($el);
} else {
// another div on the current row. Add it to the list and check if it's taller
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
// do the last row
for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
})
</script>
<?php
include('footer.php');
?>