File "debug_hall_data.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/exam_attendance/debug_hall_data.php
File size: 1.77 KiB (1815 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
header('Content-Type: application/json');
require_once '../../config/config.php';

try {
    $allocationId = $_GET['allocation_id'] ?? null;
    
    if (!$allocationId) {
        echo json_encode([
            'status' => 'error',
            'message' => 'Allocation ID is required'
        ]);
        exit;
    }
    
    // Check hall allocation
    $allocationQuery = "SELECT * FROM hall_allocations WHERE allocation_id = ?";
    $allocationStmt = $pdo->prepare($allocationQuery);
    $allocationStmt->execute([$allocationId]);
    $allocation = $allocationStmt->fetch(PDO::FETCH_ASSOC);
    
    // Check student seating
    $seatingQuery = "SELECT * FROM student_seating WHERE allocation_id = ?";
    $seatingStmt = $pdo->prepare($seatingQuery);
    $seatingStmt->execute([$allocationId]);
    $seating = $seatingStmt->fetchAll(PDO::FETCH_ASSOC);
    
    // Check student registrations
    $regQuery = "SELECT COUNT(*) as count FROM student_registrations";
    $regStmt = $pdo->query($regQuery);
    $regCount = $regStmt->fetch(PDO::FETCH_ASSOC);
    
    // Check students table
    $studentsQuery = "SELECT COUNT(*) as count FROM students";
    $studentsStmt = $pdo->query($studentsQuery);
    $studentsCount = $studentsStmt->fetch(PDO::FETCH_ASSOC);
    
    echo json_encode([
        'status' => 'success',
        'data' => [
            'allocation' => $allocation,
            'seating_count' => count($seating),
            'seating_data' => $seating,
            'student_registrations_count' => $regCount['count'],
            'students_count' => $studentsCount['count']
        ]
    ]);
    
} catch (Exception $e) {
    echo json_encode([
        'status' => 'error',
        'message' => 'Error: ' . $e->getMessage()
    ]);
}
?>

PHP File Manager