<?php

require_once './connection.php';

if (!isset($_POST['user_id']) == "") {
    $user_id = $_POST['user_id'];
//    echo '$district_id '.$district_id;
    $result = array();

    $sql = 'select *,DATE_FORMAT(created_date,"%d-%m-%Y %H:%i:%s") AS entry_Date from tbl_freez_status where user_id="'.$user_id.'" and flag="1" ORDER by id DESC Limit 0,25';
//echo 'query ' . $sql;
    try {
        if ($con) {
            mysqli_set_charset($con, 'utf8');
            $response = mysqli_query($con, $sql);
//        print_r($response);
            if (mysqli_num_rows($response) > 0) {

                while ($row = mysqli_fetch_assoc($response)) {
                    $index["id"] = $row["id"];
                    $index["user_id"] = $row["user_id"];
                    $index["freez_temperature"] = $row["freez_temperature"];
                    $index["freez_humidity"] = $row["freez_humidity"];
                    $index["created_date"] = $row["entry_Date"];

                    array_push($result, $index);
                }
//            $result["success"] = "1";
                echo json_encode($result);
            } else {
                echo 'NO_Record_Found';
            }
        } else {
            echo 'Connection Problem';
        }
    } catch (Exception $ex) {
        echo $e->getMessage();
    }
} else {
    echo 'Username is Null';
}
?>
