query($sql); $row = $result->fetch_assoc(); ?>

Home News & Events
by Admin
0 Comments

Leave a Comment

prepare("INSERT INTO comments (news_id, name, email, comment) VALUES (?, ?, ?, ?)"); $stmt->bind_param("isss", $id, $name, $email, $comment); $stmt->execute(); echo "

✅ Comment added successfully!

"; } else { echo "

❌ Please fill all fields.

"; } } // --- Fetch and display existing comments --- $get_comments = $conn->query("SELECT * FROM comments WHERE news_id = $id ORDER BY created_at DESC"); if ($get_comments->num_rows > 0) { echo "
"; while ($comment_row = $get_comments->fetch_assoc()) { echo "
" . htmlspecialchars($comment_row['name']) . " • " . date("M d, Y", strtotime($comment_row['created_at'])) . "

" . nl2br(htmlspecialchars($comment_row['comment'])) . "

"; } echo "
"; } else { echo "

No comments yet. Be the first to comment!

"; } ?>