-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
140 lines (125 loc) · 6.14 KB
/
Copy pathindex.php
File metadata and controls
140 lines (125 loc) · 6.14 KB
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
<?php
require_once __DIR__ . '/includes/db.php';
require_once __DIR__ . '/includes/auth.php';
// Global XSS escaping helper function
if (!function_exists('e')) {
function e($text) {
return htmlspecialchars($text ?? '', ENT_QUOTES, 'UTF-8');
}
}
// Master list of synchronized locations
$locations = ['Muwasco', 'Mumbi', 'Katiba', 'Mukuyu', 'Town', 'Mwangaza', 'Catho', 'VM', 'Wanjoya'];
// Database fetches
$verified = $pdo->query("SELECT p.*, (SELECT image_path FROM property_images pi WHERE pi.property_id = p.id LIMIT 1) AS image FROM properties p WHERE p.verification_status='Verified' AND p.availability='Vacant' ORDER BY p.created_at DESC LIMIT 6")->fetchAll();
$nearby = $pdo->query("SELECT p.*, (SELECT image_path FROM property_images pi WHERE pi.property_id = p.id LIMIT 1) AS image FROM properties p WHERE p.availability='Vacant' ORDER BY p.distance ASC LIMIT 4")->fetchAll();
function priceTag($p) {
return 'KSh ' . number_format($p['monthly_rent']);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EasyFind — Student Accommodation for MUT</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<?php include 'includes/navbar.php'; ?>
<section class="hero">
<div class="container">
<h1>Find your ideal student accommodation near MUT.</h1>
<p>Verified. Affordable. Reliable. Search, compare and reserve hostels before you arrive at Murang'a University of Technology.</p>
<form class="search-bar" action="student/search.php" method="get">
<select name="room_type">
<option value="">Room Type</option>
<option>Single Room</option>
<option>Bedsitter</option>
<option>One Bedroom</option>
<option>Two Bedroom</option>
</select>
<select name="location">
<option value="">Location</option>
<?php foreach ($locations as $loc): ?>
<option><?= e($loc) ?></option>
<?php endforeach; ?>
</select>
<input type="number" name="max_rent" placeholder="Max rent (KSh)">
<label class="checkbox-group" style="color:#263238;background:#fff;border-radius:6px;padding:0 10px;">
<input type="checkbox" name="verified_only" value="1"> Verified only
</label>
<button class="btn btn-primary" type="submit">Search</button>
</form>
</div>
</section>
<section class="section">
<div class="container">
<div class="section-head">
<h2>Verified Listings</h2>
<a href="student/search.php?verified_only=1">View all →</a>
</div>
<div class="grid">
<?php foreach ($verified as $p): ?>
<div class="card">
<div class="card-img" style="background-image:url('<?= e($p['image'] ?: 'assets/images/placeholder.jpg') ?>');">
<span class="badge badge-verified badge-position">✓ Verified</span>
</div>
<div class="card-body">
<h3><?= e($p['title']) ?></h3>
<div class="meta"><?= e($p['room_type']) ?> · <?= e($p['location']) ?> · <?= e($p['distance']) ?> KM from MUT</div>
<div class="price"><?= priceTag($p) ?>/mo</div>
<a href="student/property.php?id=<?= (int)$p['id'] ?>" class="btn btn-outline btn-sm" style="margin-top:10px;">View Details</a>
</div>
</div>
<?php endforeach; ?>
<?php if (!$verified): ?><p class="text-muted">No verified listings yet — check back soon.</p><?php endif; ?>
</div>
</div>
</section>
<section class="section" style="background:var(--green-100);">
<div class="container">
<div class="section-head"><h2>Nearby Houses</h2></div>
<div class="grid">
<?php foreach ($nearby as $p): ?>
<div class="card">
<div class="card-img" style="background-image:url('<?= e($p['image'] ?: 'assets/images/placeholder.jpg') ?>');"></div>
<div class="card-body">
<h3><?= e($p['title']) ?></h3>
<div class="meta"><?= e($p['distance']) ?> KM from MUT · <?= e($p['location']) ?></div>
<div class="price"><?= priceTag($p) ?>/mo</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</section>
<section class="section">
<div class="container">
<h2>Popular Locations</h2>
<div class="grid">
<?php
// Select a subset of popular locations from your master array to feature down here
$popular_subset = ['Muwasco', 'Mumbi', 'Mukuyu', 'Town', 'Mwangaza'];
foreach ($popular_subset as $loc):
?>
<a href="student/search.php?location=<?= urlencode($loc) ?>" class="card" style="padding:24px;text-align:center;">
<h3 class="mb-0"><?= e($loc) ?></h3>
<span class="text-muted">Browse houses</span>
</a>
<?php endforeach; ?>
</div>
</div>
</section>
<section class="section" style="background:var(--maroon-900);color:#fff;">
<div class="container">
<h2 style="color:#fff;">How EasyFind Works</h2>
<div class="grid">
<div><h3 style="color:var(--gold-500);">1. Search</h3><p>Filter houses by room type, price, distance and location.</p></div>
<div><h3 style="color:var(--gold-500);">2. Compare</h3><p>Check verification badges, photos and amenities.</p></div>
<div><h3 style="color:var(--gold-500);">3. Reserve</h3><p>Book your room online before you even arrive at MUT.</p></div>
</div>
</div>
</section>
<?php include 'includes/footer.php'; ?>
</body>
</html>