<?php require_once '../Connections/cmctrfdb.php'; ?>

<?php

// Connettiti al database

$conn = new mysqli($servername, $username, $password, $dbname);



$options = "<option value=''>Seleziona un controllo di qualità</option>";



$query = "SELECT idqualcheck_td, descriptionqualcheck FROM qualcheck_td WHERE idcompany = ?";

$stmt = $conn->prepare($query);



if ($stmt) {

    $stmt->bind_param("i", $idcompany);

    $stmt->execute();

    $result = $stmt->get_result();



    while ($row = $result->fetch_assoc()) {

        $id = htmlspecialchars($row['idqualcheck_td'], ENT_QUOTES, 'UTF-8');

        $description = htmlspecialchars($row['descriptionqualcheck'], ENT_QUOTES, 'UTF-8');

        $options .= "<option value='{$id}'>{$description}</option>";

    }

    $stmt->close();

}

$conn->close();



echo $options;

?>

