prepare("SELECT u.username, wa.bio FROM users u LEFT JOIN writer_applications wa ON u.id = wa.user_id WHERE u.id = ? AND u.role = 'writer'"); $stmt->execute([$author_id]); $author = $stmt->fetch(); if (!$author) { // Redirect if not a writer or doesn't exist // You might want to show a generic "user not found" page instead header("Location: index.php"); exit; } // Fetch author's books, assuming the user who added the book is the author $stmt = $pdo->prepare("SELECT id, title, author_name, description FROM books WHERE added_by_user_id = ? ORDER BY created_at DESC"); $stmt->execute([$author_id]); $books = $stmt->fetchAll(); ?>

Books by

This author has not published any books yet.