<?php
// File: getOptions.php

$db_host = "localhost";
$db_user = "akutans1";
$db_pass = "kh";
$db_name = "pt_gadai_online";
 
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);

// Periksa koneksi
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Query untuk mengambil data dari tabel kodetabungan
$sql = "SELECT kodetab,namatab FROM kodetabungan";
$result = $conn->query($sql);

$optionsData = [];

if ($result->num_rows > 0) {
    // Mengambil data setiap baris dan menyimpannya dalam array
    while ($row = $result->fetch_assoc()) {
        //$optionsData[] = $row['kodetab'] . ". " . $row['namatab'];
        $optionsData[] = $row['namatab'];
    }
}

// Mengembalikan hasil dalam format JSON
header('Content-Type: application/json');
echo json_encode($optionsData);

// Menutup koneksi
$conn->close();
?>
