JezK
Edit File: fetch_more_events.php
<?php ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); include 'db_connection.php'; $limit = isset($_POST['limit']) ? $_POST['limit'] : 0; $increment = 4; $past_events_query = "SELECT * FROM events WHERE event_date < CURDATE() ORDER BY event_date DESC LIMIT $limit, $increment"; // echo $past_events_query; $result = $conn->query($past_events_query); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $fullMonth = date('F', strtotime($row['event_date'])); $end_fullMonth = date('F', strtotime($row['event_end_date'])); $fullyear = date('Y', strtotime($row['event_date'])); $end_fullyear = date('Y', strtotime($row['event_end_date'])); $start_date = date('d', strtotime($row['event_date'])); $end_date = date('d', strtotime($row['event_end_date'])); $event_date_same = strtotime($row['event_date']); $event_end_date_same = strtotime($row['event_end_date']); ?> <div id="<?php echo $row['id']; ?>"> <a class="anchor-h" href="event_details.php?name=<?php echo urlencode(str_replace(' ', '_', $row['title'])) ?>&event_id=<?php echo base64_encode($row['id']) ?>"> <div class="cards"> <div class="card-single"> <img src="../admin/assets/events/<?php echo $row['image']; ?>" class="card-image" /> <div class="card-text"> <h6><span></span> <?php echo $row['title']; ?> </h6> <?php if ($event_date_same !== $event_end_date_same) { ?> <p><span>Date:</span> <?php if($row['event_end_date'] != '') { ?> <?php if ($start_date == $end_date) { echo $fullMonth . ' ' . $start_date . ', ' . $fullyear; } else if ($fullMonth != $end_fullMonth) { echo $fullMonth . ' ' . $start_date . ' - ' . $end_fullMonth . ' ' . $end_date . ', ' . $end_fullyear; } else { echo $fullMonth . ' ' . $start_date . ' - ' . $end_date . ', ' . $end_fullyear; } ?> <?php } else { ?> <?php echo $fullMonth . ' ' . $start_date . ', ' . $fullyear; ?> <?php } ?> </p> <?php } ?> <p><span>Location:</span> <?php echo $row['event_location']; ?> </p> </div> </div> </div> </a> </div> <?php } } else { // No more events found echo ''; } ?>