58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('log_entry.php');
|
|
$id = $_POST['result_id'];
|
|
$name =$_POST['result_name'];
|
|
$desc = $_POST['result_description'];
|
|
|
|
error_log("id: ".$id."name: ".$name." desc: ".$description);
|
|
|
|
if(!empty($id)){
|
|
$query = "update covid_test_result_master set result_name = '$name', result_description = '$desc', modified_by = '".$_SESSION['user_id']."' where id =
|
|
'".$id."' ";
|
|
}
|
|
else {
|
|
$query = "insert into covid_test_result_master(result_name,result_description,modified_by)
|
|
values ('$name','$desc','".$_SESSION['user_id']."' ); ";
|
|
}
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
else{
|
|
|
|
|
|
$query = "select max(id) id from covid_test_result_master ";
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = @mysqli_fetch_assoc($result)) {
|
|
|
|
$id_max = $row['id'];
|
|
}
|
|
}
|
|
|
|
|
|
$query = "select * from covid_test_result_master where id='".$id_max."'";
|
|
//echo $query;
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = @mysqli_fetch_assoc($result)) {
|
|
|
|
$data=$row;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
if($data==null)
|
|
{
|
|
$data['status'] = 200;
|
|
$data['message'] = "Data not found!";
|
|
}
|
|
echo json_encode($data);
|
|
?>
|