<?php

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

require_once('../Connections/cmctrfdb.php');

require_once('../webassist/mysqli/rsobj.php');



try {

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

    if ($conn->connect_error) {

        throw new Exception("Connection failed: " . $conn->connect_error);

    }



    $idtrf = $_GET['idtrf'];

    $additionalphotoslist = new WA_MySQLi_RS("additionalphotoslist", $cmctrfdb, 0);

    $additionalphotoslist->setQuery("SELECT * FROM additionalphotos WHERE additionalphotos.idtrf='$idtrf'");

    $additionalphotoslist->execute();



    $photos = [];

    while (!$additionalphotoslist->atEnd()) {

        $photos[] = [

            'filename' => $additionalphotoslist->getColumnVal("filenameadditionalphotos"),

            'description' => $additionalphotoslist->getColumnVal("descriptionadditionalphotos"),

            'id' => $additionalphotoslist->getColumnVal("idadditionalphotos")

        ];

        $additionalphotoslist->moveNext();

    }



    echo json_encode($photos);

} catch (Exception $e) {

    echo json_encode(['error' => $e->getMessage()]);

}

