-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistings.php
158 lines (120 loc) · 5.07 KB
/
listings.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
<?php
include 'components/connect.php';
if(isset($_COOKIE['user_id'])){
$user_id = $_COOKIE['user_id'];
}else{
$user_id = '';
}
include 'components/save_send.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>All Listings</title>
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
<!-- custom css file link -->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include 'components/user_header.php'; ?>
<!-- listings section starts -->
<section class="listings">
<h1 class="heading">all listings</h1>
<div class="box-container">
<?php
$total_images = 0;
$select_properties = $conn->prepare("SELECT * FROM `property` ORDER BY date DESC");
$select_properties->execute();
if($select_properties->rowCount() > 0){
while($fetch_property = $select_properties->fetch(PDO::FETCH_ASSOC)){
$select_user = $conn->prepare("SELECT * FROM `users` WHERE id = ?");
$select_user->execute([$fetch_property['user_id']]);
$fetch_user = $select_user->fetch(PDO::FETCH_ASSOC);
if(!empty($fetch_property['image_02'])){
$image_coutn_02 = 1;
}else{
$image_coutn_02 = 0;
}
if(!empty($fetch_property['image_03'])){
$image_coutn_03 = 1;
}else{
$image_coutn_03 = 0;
}
if(!empty($fetch_property['image_04'])){
$image_coutn_04 = 1;
}else{
$image_coutn_04 = 0;
}
if(!empty($fetch_property['image_05'])){
$image_coutn_05 = 1;
}else{
$image_coutn_05 = 0;
}
$total_images = (1 + $image_coutn_02 + $image_coutn_03 + $image_coutn_04 + $image_coutn_05);
$select_saved = $conn->prepare("SELECT * FROM `saved` WHERE property_id = ? and user_id = ?");
$select_saved->execute([$fetch_property['id'], $user_id]);
?>
<form action="" method="POST">
<div class="box">
<input type="hidden" name="property_id" value="<?= $fetch_property['id']; ?>">
<?php
if($select_saved->rowCount() > 0){
?>
<button type="submit" name="save" class="save"><i class="fas fa-heart"></i><span>saved</span></button>
<?php
}else{
?>
<button type="submit" name="save" class="save"><i class="far fa-heart"></i><span>save</span></button>
<?php
}
?>
<div class="thumb">
<p class="total-images"><i class="far fa-image"></i><span><?= $total_images; ?></span></p>
<img src="uploaded_files/<?= $fetch_property['image_01']; ?>" alt="">
</div>
<div class="admin">
<h3><?= substr($fetch_user['name'], 0, 1); ?></h3>
<div>
<p><?= $fetch_user['name']; ?></p>
<span><?= $fetch_property['date']; ?></span>
</div>
</div>
</div>
<div class="box">
<div class="price"><i class="fas fa-usd"></i><span><?= $fetch_property['price']; ?></span></div>
<h3 class="name"><?= $fetch_property['property_name']; ?></h3>
<p class="location"><i class="fas fa-map-marker-alt"></i><span><?= $fetch_property['address']; ?></span></p>
<div class="flex">
<p><i class="fas fa-house"></i><span><?= $fetch_property['type']; ?></span></p>
<p><i class="fas fa-tag"></i><span><?= $fetch_property['offer']; ?></span></p>
<p><i class="fas fa-bed"></i><span><?= $fetch_property['bhk']; ?> BHK</span></p>
<p><i class="fas fa-trowel"></i><span><?= $fetch_property['status']; ?></span></p>
<p><i class="fas fa-couch"></i><span><?= $fetch_property['furnished']; ?></span></p>
<p><i class="fas fa-maximize"></i><span><?= $fetch_property['carpet']; ?>sqft</span></p>
</div>
<div class="flex-btn">
<a href="view_property.php?get_id=<?= $fetch_property['id']; ?>" class="btn">view property</a>
<input type="submit" value="send enquiry" name="send" class="btn">
</div>
</div>
</form>
<?php
}
}else{
echo '<p class="empty">no properties added yet! <a href="post_property.php" style="margin-top:1.5rem;" class="btn">add new</a></p>';
}
?>
</div>
</section>
<!-- listings section ends -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
<?php include 'components/footer.php'; ?>
<!-- custom js file link -->
<script src="js/script.js"></script>
<?php include 'components/message.php'; ?>
</body>
</html>