ez-api/includes/load_comments.php

13 lines
469 B
PHP
Raw Normal View History

2024-10-29 13:13:37 +08:00
<?php
include 'db.php';
if (isset($_GET['love_wall_id'])) {
$love_wall_id = $_GET['love_wall_id'];
$stmt = $pdo->prepare("SELECT comments.content, users.username FROM comments JOIN users ON comments.user_id = users.id WHERE love_wall_id = ? ORDER BY comments.created_at DESC");
$stmt->execute([$love_wall_id]);
while ($row = $stmt->fetch()) {
echo "<div class='comment'><strong>{$row['username']}:</strong> {$row['content']}</div>";
}
}
?>