<?php
require('include/functions.php');
// Fetch messages older than 334089 (descending order)
$msgs = sb_db_get('SELECT * FROM sb_messages WHERE conversation_id = 32784 AND id < 334089 ORDER BY id DESC LIMIT 5', false);
if ($msgs) {
    foreach ($msgs as $msg) {
        echo "ID: " . $msg['id'] . "\n";
        echo "User ID: " . $msg['user_id'] . "\n";
        echo "Message: " . $msg['message'] . "\n";
        echo "Payload: " . $msg['payload'] . "\n";
        echo "Attachments: " . $msg['attachments'] . "\n";
        echo "-----------------------------------\n";
    }
} else {
    echo "No older messages found.\n";
}
?>
