File "read_select.php"
Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/read_select.php
File size: 681 B
MIME-type: text/x-php
Charset: utf-8
<?php
require_once '../../config/config.php';
header('Content-Type: application/json');
try {
$stmt = $pdo->prepare("
SELECT department_id, department_code, department_name
FROM departments
WHERE status = 'Active'
ORDER BY department_code ASC
");
$stmt->execute();
$departments = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode([
"status" => "success",
"data" => $departments
]);
} catch (Throwable $e) {
http_response_code(500);
echo json_encode([
"status" => "error",
"message" => "An error occurred while fetching departments."
]);
}
?>