<?php

require_once "config.php";

header('Content-Type: application/json');

$method = $_SERVER['REQUEST_METHOD'];

switch ($method) {
    case 'GET':
        $query = $conn->prepare("SELECT * FROM tbbarangdiskonheader where status = '1' LIMIT 1");
        $query->execute();
        $result = $query->get_result(); 
        // $data = $result->fetch_all(MYSQLI_ASSOC);
        // echo json_encode($data);
        
        $data = $result->fetch_assoc();
        $data['status'] = (int)$data['status'];

        echo json_encode($data);

        break;
}

mysqli_close($conn);
?>
