isLoggedIn()) { die('Unauthorized'); } $db = Database::getInstance(); $project_id = isset($_GET['project_id']) ? (int)$_GET['project_id'] : 0; if (!$project_id) { die('Invalid project ID'); } // Verify user has access to this project $stmt = $db->prepare("SELECT id FROM projects WHERE id = ? AND created_by = ?"); $stmt->bind_param('ii', $project_id, $_SESSION['user_id']); $stmt->execute(); if ($stmt->get_result()->num_rows === 0) { die('Access denied'); } // Get all attributes for the selection form $attributes = $db->query("SELECT id, name, choice_type, choices FROM attributes ORDER BY created_at ASC"); // Get all previously used panelist IDs in this project's selections to exclude them from available count $stmt = $db->prepare(" SELECT DISTINCT panelist_id FROM selection_members sm JOIN selections s ON sm.selection_id = s.id WHERE s.project_id = ? "); $stmt->bind_param('i', $project_id); $stmt->execute(); $used_panelists_result = $stmt->get_result(); $used_panelists = []; while ($row = $used_panelists_result->fetch_assoc()) { $used_panelists[] = $row['panelist_id']; } // Convert used panelists to JSON for JavaScript $used_panelists_json = json_encode($used_panelists); // Get total available (unused) panelists count $used_panelists_str = empty($used_panelists) ? "''" : "'" . implode("','", $used_panelists) . "'"; $available_count_query = "SELECT COUNT(*) as count FROM panel_data WHERE panelist_id NOT IN ($used_panelists_str)"; $available_count_result = $db->query($available_count_query); $available_count = 0; if ($available_count_result) { $available_count = $available_count_result->fetch_assoc()['count']; } ?>
Give this selection a descriptive name

Filter Criteria

num_rows > 0): ?> fetch_assoc()): ?>

No attributes found. Please add attributes in the Base section first.

Available Samples:
Required Sample Size: