prepare("INSERT INTO resources (title, description, teacher_id, school_id, grade, subject) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$title, $description, $user_id, $school_id, $grade, $subject]); $success = "Resource shared successfully!"; } catch (PDOException $e) { $error = "Failed to share resource: " . $e->getMessage(); } } // Handle Forum Post if (isset($_POST['create_post'])) { $title = $_POST['title']; $content = $_POST['content']; try { $stmt = db()->prepare("INSERT INTO forum_posts (title, content, author_id, school_id) VALUES (?, ?, ?, ?)"); $stmt->execute([$title, $content, $user_id, $school_id]); $success = "Topic posted successfully!"; } catch (PDOException $e) { $error = "Failed to post topic: " . $e->getMessage(); } } // Fetch Resources $resources = db()->prepare("SELECT r.*, u.email as teacher_email FROM resources r JOIN users u ON r.teacher_id = u.id WHERE r.school_id = ? ORDER BY r.created_at DESC"); $resources->execute([$school_id]); $resources = $resources->fetchAll(); // Fetch Forum Posts $posts = db()->prepare("SELECT p.*, u.email as author_email, (SELECT COUNT(*) FROM forum_comments WHERE post_id = p.id) as comment_count FROM forum_posts p JOIN users u ON p.author_id = u.id WHERE p.school_id = ? ORDER BY p.created_at DESC"); $posts->execute([$school_id]); $posts = $posts->fetchAll(); $pageTitle = "Teacher Collaboration Hub"; include 'includes/header.php'; ?>
No resources shared yet. Be the first!
Start a conversation with your colleagues.