Code restructure push
This commit is contained in:
24
index.php
24
index.php
@@ -3,7 +3,7 @@ $headerStyle = 'dark';
|
||||
include_once('header.php');
|
||||
$indemnityPending = false;
|
||||
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
if (isset($_SESSION['user_id']) && isset($conn) && $conn !== null) {
|
||||
$userId = $_SESSION['user_id'];
|
||||
$stmt = $conn->prepare("SELECT user_id FROM membership_application WHERE user_id = ? AND accept_indemnity = 0 LIMIT 1");
|
||||
$stmt->bind_param("i", $userId);
|
||||
@@ -83,17 +83,18 @@ if (countUpcomingTrips() > 0) { ?>
|
||||
<div class="row justify-content-center">
|
||||
<?php
|
||||
// Query to retrieve data from the trips table
|
||||
$stmt = $conn->prepare("SELECT trip_id, trip_name, location, short_description, start_date, end_date, vehicle_capacity, cost_members, places_booked
|
||||
FROM trips
|
||||
WHERE published = ?
|
||||
ORDER BY trip_id DESC
|
||||
LIMIT 4");
|
||||
$published = 1;
|
||||
$stmt->bind_param("i", $published);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
if (isset($conn) && $conn !== null) {
|
||||
$stmt = $conn->prepare("SELECT trip_id, trip_name, location, short_description, start_date, end_date, vehicle_capacity, cost_members, places_booked
|
||||
FROM trips
|
||||
WHERE published = ?
|
||||
ORDER BY trip_id DESC
|
||||
LIMIT 4");
|
||||
$published = 1;
|
||||
$stmt->bind_param("i", $published);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
if ($result->num_rows > 0) {
|
||||
// Loop through each row
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$trip_id = $row['trip_id'];
|
||||
@@ -131,6 +132,7 @@ if (countUpcomingTrips() > 0) { ?>
|
||||
} else {
|
||||
echo "No trips available.";
|
||||
}
|
||||
} // end if (isset($conn) && $conn !== null)
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user