Fix Sort Newest to oldest in notifications

This commit is contained in:
johnnyq
2025-02-27 11:22:02 -05:00
parent fded8177c5
commit 4529a56d7b
+25 -19
View File
@@ -1,11 +1,13 @@
<?php
require_once '../includes/ajax_header.php';
require_once "../includes/ajax_header.php";
$sql = mysqli_query($mysqli, "SELECT * FROM notifications
$sql = mysqli_query(
$mysqli,
"SELECT * FROM notifications
WHERE notification_user_id = $session_user_id
AND notification_dismissed_at IS NULL
ORDER BY notification_id"
ORDER BY notification_id DESC"
);
$num_notifications = mysqli_num_rows($sql);
@@ -24,16 +26,22 @@ ob_start();
<div class="modal-body bg-white">
<?php if ($num_notifications) { ?>
<?php
<?php while ($row = mysqli_fetch_array($sql)) {
while ($row = mysqli_fetch_array($sql)) {
$notification_id = intval($row['notification_id']);
$notification_type = nullable_htmlentities($row['notification_type']);
$notification_details = nullable_htmlentities($row['notification']);
$notification_action = nullable_htmlentities($row['notification_action']);
$notification_timestamp_formated = date('M d g:ia',strtotime($row['notification_timestamp']));
$notification_client_id = intval($row['notification_client_id']);
if(empty($notification_action)) { $notification_action = "#"; }
$notification_id = intval($row["notification_id"]);
$notification_type = nullable_htmlentities($row["notification_type"]);
$notification_details = nullable_htmlentities($row["notification"]);
$notification_action = nullable_htmlentities(
$row["notification_action"]
);
$notification_timestamp_formated = date(
"M d g:ia",
strtotime($row["notification_timestamp"])
);
$notification_client_id = intval($row["notification_client_id"]);
if (empty($notification_action)) {
$notification_action = "#";
}
?>
@@ -50,10 +58,7 @@ ob_start();
</a>
<?php
}
} else {
?>
}} else { ?>
<div class="text-center text-secondary py-5">
<i class='far fa-6x fa-bell-slash'></i>
<h3 class="mt-3">No Notifications</h3>
@@ -62,7 +67,9 @@ ob_start();
</div>
<div class="modal-footer bg-white justify-content-end">
<?php if ($num_notifications) { ?>
<a href="post.php?dismiss_all_notifications&csrf_token=<?php echo $_SESSION['csrf_token'] ?>" class="btn btn-primary">
<a href="post.php?dismiss_all_notifications&csrf_token=<?php echo $_SESSION[
"csrf_token"
]; ?>" class="btn btn-primary">
<span class="text-white text-bold"><i class="fas fa-check mr-2"></i>Dismiss all</span>
</a>
<?php } else { ?>
@@ -75,5 +82,4 @@ ob_start();
</button>
</div>
<?php
require_once "../includes/ajax_footer.php";
<?php require_once "../includes/ajax_footer.php";