File: /var/www/nclive/backend/sp_exam_api/create_json_file_for_notification.php
<?php
include "/var/www/nclive/backend/config.php";
$outputFile = __DIR__ . "/notification_data.json"; // File to store JSON
// Run the query
$sql = "SELECT notify.id, notify.title, notify.exam_id, notify.state_id, notify.expiry_date, notify.added_by, notify.status, notify.display_order, notify.add_date,exam.exam_name,exam.url_slug,state.state_name, exam.sp_exam_id FROM sp_notification as notify LEFT JOIN sp_exam as exam on exam.exam_id=notify.exam_id LEFT JOIN sp_states as state on state.state_id=notify.state_id where CURDATE() <= notify.expiry_date and notify.status='1' and notify.notif_type='Exam' order by notify.display_order desc";
$stmt = $db->query($sql);
$rows = $stmt->fetchAll();
// Organize all data for fast API access
$organized = [];
foreach ($rows as $row) {
$organized[] = $row;
}
// Save as JSON
file_put_contents($outputFile, json_encode($organized, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
echo "✅ JSON file generated successfully at: $outputFile\n";