-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.php
192 lines (157 loc) · 7.55 KB
/
index2.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
<?php
include_once("includes/functions.php");
$limit = 14;
if (isset($_GET["page"])) {
$page = $_GET["page"];
}
else{
$page=1;
};
$start_from = ($page-1) * $limit;
?>
<!DOCTYPE html>
<head>
<title>nstumart</title>
<!-- favicon -->
<link rel="shortcut icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="assets/css/style.css?v=<?php echo time(); ?>">
<!-- <link rel="stylesheet" type="text/css" href="assets/css/style.css"/> -->
<script>
function getareas(cid){
$(document).ready(function(){
$.get("getAreas.php?cid="+cid, function(data, status){
$("#areaDiv").html(data);
});
});
}
</script>
</head>
<style>
.card:hover{
transform: scale(1.05);
box-shadow: 0 10px 20px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
}
ul{
margin-bottom:200px;
}
</style>
<body>
<?php
drawHeader(1);
?>
<div class="container ">
<div class="control d-flex justify-content-around">
<div class="search text-center">
<form style="margin-top: 0px"method="get" action="index.php" class=" ">
<select class="select " name="Maincategory">
<option value='0'>CategoryName</option>
<?php
$resultcategories=mysqli_query($clink,"SELECT CategoryID , CategoryName FROM categories");
while ($rowcategories=mysqli_fetch_assoc($resultcategories)){
echo "<option value='{$rowcategories['CategoryID']}'>{$rowcategories['CategoryName']}</option>";
}
?>
</select><input type="submit" class="btn clicksearch" value="search">
</form>
</div>
</div>
</div>
<div class='container'style="padding-right: 32px;">
<div class="btn-group btn-group-justified col-sm-12 m-2">
<a href="index.php?pricedp" class="btn btnselect ">Lowest price</a>
<a href="index.php?pricepd" class="btn btnselect ">Highest price</a>
<a href="index.php?New" class="btn btnselect ">New</a>
</div>
</div>
<section class="ads">
<div class="container">
<div class="row ">
<?php
//Get DB products and display them
if (isset($_GET['pricedp'])){
$result = mysqli_query($clink, "SELECT * FROM `advertisments` ORDER BY `advertisments`.`Price` ASC LIMIT $start_from, $limit ");
}else if (isset($_GET['pricepd'])){
$result = mysqli_query($clink, "SELECT * FROM `advertisments` ORDER BY `advertisments`.`Price` DESC LIMIT $start_from, $limit ");
}else if (isset($_GET['New'])){
$result = mysqli_query($clink, "SELECT * FROM `advertisments` ORDER BY `advertisments`.`AdsID` DESC LIMIT $start_from, $limit ");
}else if (isset($_GET['Maincategory'] ) AND $_GET['Maincategory'] !=0){
$categoryID =$_GET['Maincategory'];
$result = mysqli_query($clink, "SELECT * FROM advertisments , categories where categories.CategoryID= $categoryID and advertisments.CategoryID = categories.CategoryID LIMIT $start_from, $limit");
}else {
$result = mysqli_query($clink, "SELECT * FROM `advertisments` ORDER BY `advertisments`.`Details` ASC LIMIT $start_from, $limit ");
}
if(mysqli_num_rows($result)>0){
//Show them
while($row = mysqli_fetch_assoc($result)){
if($row['Status'] == 1 || isLogged() == 2 ) {
echo "<div class=' col-lg-3 col-md-6 col-sm-10 offset-md-0 offset-sm-1 mb-3 '>
<div class='text-center card h-100' >
<a href='pageads.php?ADS-ID={$row['AdsID']}' >
<img class='' src='assets/img/{$row['Image']}' class='card-img-top img-fluid' alt='...'>
</a>
<span class='float-left'> Tk {$row['Price']}</span>
<div class='card-body p-0'>
<h5 style='display:inline-block' class='card-title'>{$row['Title']}</h5>
<a href='pageads.php?ADS-ID={$row['AdsID']}' class='btn btn-primary more'>More Details</a>
";
if ($row['Status'] == 1 &&(isLogged() == 2) ){
echo "<a href='adsshoworhide.php?ADS-ID={$row['AdsID']}' class='btn btn-danger ml-2 ' >Hide</a>";
}else if ($row['Status'] == 0 &&(isLogged() == 2) ) {
echo "<a href='adsshoworhide.php?ADS-ID={$row['AdsID']}' class='btn btn-primary ml-2 ' >Show</a>";
}
echo" </div> </div></div>";
}
}
}else{
outputMessage("No products found in our catalog",'warning');
}
?>
</div>
</div>
<?php
global $clink;
$result_db = mysqli_query($clink,"SELECT COUNT(AdsID) FROM advertisments");
$row_db = mysqli_fetch_row($result_db);
$total_records = $row_db[0];
$total_pages = ceil($total_records / $limit);
/* echo $total_pages; */
echo '<ul style="margin-top: 50px;position:relative;z-index:1;" class="pagination justify-content-center">';
if($page > 1)
{
echo '<li class="page-item ">
<a class="page-link" href="index.php?page='.($page - 1).'">Previous</a>
</li>';
}
for($i=1; $i<=$total_pages; $i++)
{
if($i == $page){
$active = "active";
}
else{
$active = "";
}
echo '<li class="page-item '.$active.' ">
<a class="page-link" href="index.php?page='.$i.'">'.$i.'</a>
</li>';
}
if($total_pages > $page)
{
echo '<li class="page-item '.$active.' ">
<a class="page-link" href="index.php?page='.($page + 1).'">Next</a>
</li>';
}
echo '</ul>';
?>
<?php
include_once("footer.php");
?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="assets/js/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>