<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);

$sql = "SELECT idcompoundsvocabulary, namecompoundsvocabulary, cascompoundvocabulary FROM compundsvocabulary WHERE preferred='Y'";
$result = $conn->query($sql);

$data = [];
while ($row = $result->fetch_assoc()) {
    $data[] = [
        'id' => $row['idcompoundsvocabulary'],
        'text' => $row['namecompoundsvocabulary'] . ' (' . $row['cascompoundvocabulary'] . ')'
    ];
}

echo json_encode($data);
$conn->close();
