prepare($sql);
if ($stmt) {
// Bind the parameter
$stmt->bind_param("i", $trip_id);
// Execute the query
$stmt->execute();
// Get the result
$result = $stmt->get_result();
// Check if the trip exists
if ($result->num_rows > 0) {
// Fetch the data
$row = $result->fetch_assoc();
// Populate the variables
$trip_id = $row['trip_id'];
$trip_name = $row['trip_name'];
$location = $row['location'];
$short_description = $row['short_description'];
$long_description = $row['long_description'];
$start_date = $row['start_date'];
$end_date = $row['end_date'];
$capacity = $row['vehicle_capacity'];
$cost_members = $row['cost_members'];
$cost_nonmembers = $row['cost_nonmembers'];
$cost_pensioner = $row['cost_pensioner'];
$cost_pensioner_member = $row['cost_pensioner_member'];
$member_discount = $cost_nonmembers - $cost_members;
$member_discount_pensioner = $cost_pensioner - $cost_pensioner_member;
$places_booked = $row['places_booked'];
$booking_fee = $row['booking_fee'];
$remaining_places = getAvailableSpaces($trip_id);
// Determine the badge text based on the status
$badge_text = ($remaining_places > 0) ? $remaining_places . ' PLACES LEFT!!' : 'FULLY BOOKED';
// Convert newlines into
tags to preserve line breaks
$formatted_description = nl2br($long_description);
// Wrap the text in
tags at the beginning and end $formatted_description = '
' . $formatted_description . '
'; } else { echo "No trip found with ID: $trip_id"; } // Close the statement $stmt->close(); } else { echo "Error preparing the statement: " . $conn->error; } // Always close the database connection when done $conn->close(); ?>