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

45 lines
1.3 KiB
PHP

<?php
include('includes/config/config.php');
include('log_entry.php');
include('includes/functions.php');
// Get POST data
$ggrc_no = isset($_POST['ggrc_no']) ? mysqli_real_escape_string($conn, $_POST['ggrc_no']) : '';
$drip_id = isset($_POST['drip_id']) ? mysqli_real_escape_string($conn, $_POST['drip_id']) : '';
if($drip_id){
$edit_filter ="and drip_id != '$drip_id'";
}else{
$edit_filter ="";
}
// Prepare the SQL query
$sql = "SELECT * FROM beneficiary_drip_add_details WHERE ggrc_no = '$ggrc_no' $edit_filter";
error_log($sql."golu");
$result = mysqli_query($conn, $sql);
// Initialize response array
$response = [];
if ($result) {
if (mysqli_num_rows($result) > 0) {
// Fetch the record
$row = mysqli_fetch_assoc($result);
$response['id'] = $row['id']; // Assuming 'id' is the column name for the patient ID
$response['status'] = 'success';
} else {
// No record found
$response['status'] = 'error';
$response['message'] = 'No record found for the provided ggrc_no number.';
}
} else {
// Query execution error
$response['status'] = 'error';
$response['message'] = 'Database query failed: ' . mysqli_error($conn);
}
// Return the response as JSON
header('Content-Type: application/json');
echo json_encode($response);
?>