prepare("INSERT INTO resources (title, description, teacher_id, school_id, grade, subject, is_public) VALUES (?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([$title, $description, $user_id, $school_id, $grade, $subject, $is_public]); $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']; $is_public = isset($_POST['is_public']) ? 1 : 0; try { $stmt = db()->prepare("INSERT INTO forum_posts (title, content, author_id, school_id, is_public) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$title, $content, $user_id, $school_id, $is_public]); $success = "Topic posted successfully!"; } catch (PDOException $e) { $error = "Failed to post topic: " . $e->getMessage(); } } // Fetch Resources (Own school or Public from other schools) $resources_query = " SELECT r.*, u.email as teacher_email, s.name as school_name FROM resources r JOIN users u ON r.teacher_id = u.id JOIN schools s ON r.school_id = s.id WHERE r.school_id = :school_id OR r.is_public = 1 ORDER BY r.created_at DESC "; $resources_stmt = db()->prepare($resources_query); $resources_stmt->execute(['school_id' => $school_id]); $resources = $resources_stmt->fetchAll(); // Fetch Forum Posts (Own school or Public from other schools) $posts_query = " SELECT p.*, u.email as author_email, s.name as school_name, (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 JOIN schools s ON p.school_id = s.id WHERE p.school_id = :school_id OR p.is_public = 1 ORDER BY p.created_at DESC "; $posts_stmt = db()->prepare($posts_query); $posts_stmt->execute(['school_id' => $school_id]); $posts = $posts_stmt->fetchAll(); $pageTitle = "School Collaboration Hub"; include 'includes/header.php'; ?>
Share resources and ideas with your school and the wider community.
No resources shared yet. Be the first!
Start a conversation with your colleagues.