<?php
// get_post_details.php
include_once 'model/posts_model.php';

if (isset($_GET['id'])) {
    $postId = $_GET['id'];
    $posts_model = new posts_model();

    // Fetch the post details from the database
    $post = $posts_model->get_post_by_id($postId);

    if ($post) {
        // Return the post data as JSON
        echo json_encode([
            'success' => true,
            'post' => $post
        ]);
    } else {
        echo json_encode(['success' => false]);
    }
}
?>
