35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
include('include/headscript.php');
|
|
|
|
$dbHandler = DBHandlerSelect::getInstance();
|
|
$pdo = $dbHandler->getConnection();
|
|
|
|
$iddatadb = $_GET['iddatadb'] ?? null;
|
|
|
|
if (!$iddatadb) {
|
|
echo json_encode(['success' => false, 'message' => 'ID TRF mancante']);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
// Adjust the query to select all photo paths for the given iddatadb
|
|
$stmt = $pdo->prepare("SELECT file_path FROM datadb_photos WHERE iddatadb = :iddatadb");
|
|
$stmt->execute([':iddatadb' => $iddatadb]);
|
|
$photos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
if ($photos && count($photos) > 0) {
|
|
// Prepare an array of full file paths
|
|
$photoPaths = array_map(function($photo) {
|
|
return '../photostrf/' . $photo['file_path']; // Assuming the photos are stored in the "photostrf" folder
|
|
}, $photos);
|
|
|
|
echo json_encode(['success' => true, 'photos' => $photoPaths]); // Return an array of photo paths
|
|
} else {
|
|
echo json_encode(['success' => false, 'message' => 'Nessuna foto trovata']);
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo json_encode(['success' => false, 'message' => 'Errore nel caricamento: ' . $e->getMessage()]);
|
|
}
|