'.$title.''; if($_GET['sort'] == 'desc'){ echo '
Sort Oldest First
'; $query = ' SELECT *, salemtsh_history.title as news_title, salemtsh_history.image as news_image, salemtsh_users.id as author_id, salemtsh_history.id as history_id, salemtsh_offices.title as author_title FROM salemtsh_history LEFT JOIN salemtsh_users ON salemtsh_history.author = salemtsh_users.id LEFT JOIN salemtsh_offices ON salemtsh_users.office = salemtsh_offices.id ORDER BY date DESC, salemtsh_history.id '; }else{ echo '
Sort Newest First
'; $query = ' SELECT *, salemtsh_history.title as news_title, salemtsh_history.image as news_image, salemtsh_users.id as author_id, salemtsh_history.id as history_id, salemtsh_offices.title as author_title FROM salemtsh_history LEFT JOIN salemtsh_users ON salemtsh_history.author = salemtsh_users.id LEFT JOIN salemtsh_offices ON salemtsh_users.office = salemtsh_offices.id ORDER BY date, salemtsh_history.id '; } $result = mysqli_query($conn, $query); if (!$result) { die("Error in SQL query: " . mysqli_error($conn)); } $previousDate = null; while($row = mysqli_fetch_array($result)) { $currentDate = $row['date']; // Check if the current date is different from the previous date if ($currentDate != $previousDate) { // Close the previous date group if not the first iteration if ($previousDate !== null) { echo ''; // Close the previous date group } // Start a new date group echo '
'; echo '
'.$row['date'].'
'; } echo '
'; echo '
'; echo '

'.$row['news_title'].'

'.PHP_EOL; if ($validated == 1) { echo ' '; } // Needs closing
if(!empty($row['news_image']) OR !empty($row['video'])){ if($side == 'left'){ $side = 'right'; }else{ $side = 'left'; } } echo '
'.PHP_EOL; if(!empty($row['news_image'])){ echo ''.$row['news_title'].''.PHP_EOL; }elseif(!empty($row['video'])){ echo ''.PHP_EOL; } echo '

'.nl2br($row['content']); require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/author.php'; echo '

'.PHP_EOL; echo '
'.PHP_EOL; echo '
'.PHP_EOL; echo '
'.PHP_EOL; $previousDate = $currentDate; // Update the previousDate for the next iteration } echo '
Do you have some history we are missing? Contact '.$admin.'! Be sure to include a date or at least a year, complete details and an image if you have it.
'; // Close the last date group if ($previousDate !== null) { echo '
'; } require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/after.php'; ?>