-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworld.php
179 lines (160 loc) · 4.88 KB
/
world.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
<?php
session_start();
error_reporting(0);
include('includes/config.php');
// Fetch data based on the selected service type
$selectedServiceType = $_GET['service_type'] ?? 'shelter'; // Default to 'shelter'
// Initialize an empty array to store service data
$serviceData = array();
try {
// Define your SQL query to fetch service data from the corresponding table
$serviceTable = ''; // Define the variable to hold the table name based on the selectedServiceType
switch ($selectedServiceType) {
case 'shelter':
$serviceTable = 'shelters';
break;
case 'food_bank':
$serviceTable = 'food_banks';
break;
case 'organization':
$serviceTable = 'outside_organizations';
break;
}
if (!empty($serviceTable)) {
$serviceSql = "SELECT * FROM $serviceTable";
$serviceQuery = $dbh->prepare($serviceSql);
$serviceQuery->execute();
while ($service = $serviceQuery->fetch(PDO::FETCH_ASSOC)) {
$serviceData[] = $service;
}
}
} catch (PDOException $e) {
// Handle database-related errors when fetching service data
$serviceErrorMsg = "Error: " . $e->getMessage();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTH World Services</title>
<link rel="stylesheet" href="css/style.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #333;
margin: 0;
padding: 0;
text-align: center;
}
h1 {
color: #debf12;
}
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
}
.item {
border: 1px solid #ccc;
padding: 10px;
text-align: center;
}
.about-container {
text-align: center;
background-color: #333;
padding: 20px;
box-shadow: 0 0 10px #34bcaa;
margin-right: 5%;
margin-left: 5%;
border-radius: 15px;
}
.about-container h2 {
font-size: 24px;
color: #34bcaa;
}
.about-container p {
font-size: 16px;
color: #fff;
}
select {
padding: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}
select option {
font-size: 16px;
background-color: #fff;
color: #333;
}
select option:hover {
background-color: #ddd;
}
.service-cards {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 20px;
}
.service-card {
border: 1px solid #ccc;
padding: 20px;
border-radius: 10px;
background-color: #333;
width: calc(33.33% - 20px);
}
.service-card h3 {
font-size: 24px;
color: #debf12;
}
.service-card p {
font-size: 16px;
color: #fff;
}
</style>
</head>
<body style="background-color: #333">
<header>
<h1>Welcome to HTH World</h1>
<p style="color: #debf12">Helping the Community Together</p>
</header>
<?php
// Include the navigation bar
include('navbar.php');
?>
</br>
</br>
<div class="about-container">
<h1>HTH Services</h1>
<!-- Display entries for the selected service type -->
<h2>Resources</h2>
<select onchange="location = this.value;">
<option value="world.php?service_type=shelter" <?php if ($selectedServiceType === 'shelter') echo 'selected'; ?>>Shelters</option>
<option value="world.php?service_type=food_bank" <?php if ($selectedServiceType === 'food_bank') echo 'selected'; ?>>Food Banks</option>
<option value="world.php?service_type=organization" <?php if ($selectedServiceType === 'organization') echo 'selected'; ?>>Organizations</option>
</select>
<?php if (!empty($serviceData)) : ?>
<div class="service-cards">
<?php foreach ($serviceData as $service) : ?>
<div class="service-card">
<h3><?php echo $service['name']; ?></h3>
<p><strong>Address:</strong> <?php echo $service['address']; ?></p>
<p><strong>Contact Email:</strong> <?php echo $service['contact_email']; ?></p>
<p><strong>Contact Phone:</strong> <?php echo $service['contact_phone']; ?></p>
<p><strong>Services:</strong> <?php echo $service['services']; ?></p>
</div>
<?php endforeach; ?>
</div>
<?php else : ?>
<p>No entries found.</p>
<?php endif; ?>
</div>
</br>
<?php
// Include the footer
include('footer.php');
?>
</body>
</html>