56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
$hygSampleId = $_POST['hygSampleId'];
|
|
echo $hygSampleId;
|
|
$hygSampleName =$_POST['hygSampleName'];
|
|
$sampleDescription = $_POST['sampleDescription'];
|
|
|
|
if(!empty($hygSampleId)){
|
|
$query = "update hygiene_sample set sample_name = '$hygSampleName', sample_description = '$sampleDescription',modified_by = '".$_SESSION['user_id']."' where hyg_sample_id =
|
|
'".$hygSampleId."' ";
|
|
}
|
|
else {
|
|
$query = "insert into hygiene_sample(sample_name,sample_description,modified_by)
|
|
values ('$hygSampleName','$sampleDescription','".$_SESSION['user_id']."' ); ";
|
|
}
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
else{
|
|
|
|
|
|
$query = "select max(hyg_sample_id) hyg_sample_id from hygiene_sample ";
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
exit(mysqli_error($conn));
|
|
}
|
|
if(mysqli_num_rows($result) > 0) {
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
$hyg_sample_id_max = $row['hyg_sample_id'];
|
|
}
|
|
}
|
|
|
|
|
|
$query = "select * from hygiene_sample where hyg_sample_id='".$hyg_sample_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);
|
|
?>
|