<?php
include_once("../../../../../lib/konfig.php"); 
$MySQLi = new MySQLi($strDBHostName, $strDBUsername, $strDBPassword, $strDBName);

if(isset($_POST['strDeskripsi'])) {
    $strDeskripsi = $MySQLi->real_escape_string($_POST['strDeskripsi']);
    $query="SELECT strUnit, 
                   strUnit2, 
                   strUnit3 
            FROM item 
            WHERE strDeskripsi = '".$strDeskripsi."'
            ";
    $result = $MySQLi->query($query);
    $units = array();
    if($result) 
    {
        $row = $result->fetch_assoc();
        if ($row['strUnit']) $units[] = $row['strUnit'];
        if ($row['strUnit2']) $units[] = $row['strUnit2'];
        if ($row['strUnit3']) $units[] = $row['strUnit3'];
        $result->free();
    } 
    else 
        echo "Error: " . $MySQLi->error;
    $MySQLi->close();
    echo json_encode($units);
} else echo "Error: strDeskripsi tidak ditemukan dalam permintaan POST";
?>