27 lines
741 B
PHP
27 lines
741 B
PHP
<?php
|
|
include 'includes/config/config.php'; // Add your database connection file
|
|
|
|
if (isset($_POST['batch'])) {
|
|
$batch_id = $_POST['batch'];
|
|
|
|
// Query to check if batch_id exists in the table
|
|
$query = "SELECT id FROM training_batch_enrollment WHERE batch_id = ?";
|
|
$stmt = $conn->prepare($query);
|
|
$stmt->bind_param("i", $batch_id);
|
|
$stmt->execute();
|
|
$stmt->store_result();
|
|
|
|
if ($stmt->num_rows > 0) {
|
|
$stmt->bind_result($id);
|
|
$stmt->fetch();
|
|
// Return response if the batch exists
|
|
echo json_encode(['exists' => true, 'id' => $id]);
|
|
} else {
|
|
// Return response if the batch doesn't exist
|
|
echo json_encode(['exists' => false]);
|
|
}
|
|
|
|
$stmt->close();
|
|
}
|
|
?>
|