csrtechnew.ohctech.in/get_course_info.php
2025-04-14 13:28:09 +05:30

43 lines
1.6 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/auth/auth.php');
include('includes/functions.php');
include('log_entry.php');
// Check if batch_id is provided
if (isset($_POST['batch_id'])) {
$batch_id = $_POST['batch_id'];
// Get the training program ID based on the batch ID
$training_program_id = getFieldFromTable('training_program_id', 'training_batch_master', 'batch_id', $batch_id);
// Get the course name based on the training program ID
$course_name = getFieldFromTable('name', 'courses', 'id', $training_program_id);
// Get the subjects based on the training program ID
$subject = getFieldFromTable('subjects', 'courses', 'id', $training_program_id);
// Convert the subjects string to an array
$subjectArray = explode(',', $subject);
// Initialize an empty string for options
$options = '';
// Loop through each subject ID to create option elements
$options .= '<option style="text-align: center;" value="" selected disabled>Select Option</option>';
foreach ($subjectArray as $i) {
$subject_name = getFieldFromTable('subject_name', 'subjects', 'subject_id', intval($i)); // Ensure the ID is an integer
error_log("check_subject_name : ".$subject_name);
if ($subject_name) {
$options .= "<option style=\"text-align: center;\" value=\"$i\">$subject_name</option>"; // Use double quotes for HTML
}
}
// Return the course name and options
echo json_encode([
'course_name' => $course_name,
'options' => $options
]);
}
?>