Converted queries in: - functions.php: * countUpcomingTrips() - Trip count query * getNextOpenDayDate() - Next open day event lookup - campsites.php: * All campsites query for map display - fetch_users.php: * User list query (AJAX handler) - get_campsites.php: * Campsites with user join (AJAX handler) All now use prepared statements with proper parameter binding. Progress: 12/21 queries converted. Remaining: fetch_drinks, fetch_bar_tabs, admin pages (legacy_members queries), bush_mechanics course query
38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
require_once("env.php");
|
|
include_once('connection.php');
|
|
include_once('functions.php');
|
|
$conn = openDatabaseConnection();
|
|
|
|
$stmt = $conn->prepare("SELECT
|
|
c.*,
|
|
u.first_name,
|
|
u.last_name,
|
|
u.profile_pic
|
|
FROM campsites c
|
|
LEFT JOIN users u ON c.user_id = u.user_id");
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
$campsites = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$campsites[] = [
|
|
'id' => $row['id'],
|
|
'name' => $row['name'],
|
|
'description' => $row['description'],
|
|
'website' => $row['website'],
|
|
'telephone' => $row['telephone'],
|
|
'latitude' => $row['latitude'],
|
|
'longitude' => $row['longitude'],
|
|
'thumbnail' => $row['thumbnail'],
|
|
'user' => [
|
|
'first_name' => $row['first_name'],
|
|
'last_name' => $row['last_name'],
|
|
'profile_pic' => $row['profile_pic']
|
|
]
|
|
];
|
|
}
|
|
|
|
header('Content-Type: application/json');
|
|
echo json_encode($campsites);
|