ESH/select_recommended_tests.php
2024-10-23 18:28:06 +05:30

36 lines
936 B
PHP

<?php
include('includes/config/config.php');
$sections = "select checkup_form_section_ids from checkup_type where checkup_type_code='LAB_TEST'";
$result_ids = mysqli_query($conn, $sections);
$rows = mysqli_fetch_assoc($result_ids);
$ids = $rows['checkup_form_section_ids'];
error_log("ids " . $ids);
if (!empty($ids)) {
$idsArray = explode(',', $ids);
$idsString = "'" . implode("','", $idsArray) . "'";
} else {
$idsString = "''";
}
$query = "select section_name as test_name from checkup_form_section where section_id in ($idsString) ";
error_log("recommended test query " . $query);
if (!$result = @mysqli_query($conn, $query)) {
exit(mysqli_error($conn));
}
$data = array();
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$data[] = $row['test_name'];
}
} else {
$data['status'] = 200;
$data['message'] = "Data not found!";
}
echo json_encode($data);