Nel tuo codice, qui
Codice PHP:
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $file)
{
$file = $file->getFilename();
}
ad ogni iterazione sovrascrivi la variabile $file, per questo ti risulta sempre l'ultimo nome di file.
D'altro canto $file è una variabile semplice, non un array, quindi è anche normale che alla fine ci sia una sola stringa all'interno, ed ancora, usi lo stesso nome di variabile per 2 cose diverse.
Io il tuo codice lo cambierei così
Codice PHP:
<?php
$sqlSelect = "SELECT * FROM wrin WHERE modulo = '$modulo' ";
$result = mysqli_query($conn, $sqlSelect);
$path = 'pdf/'.$modulo;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $file)
{
$files[] = $file->getFilename();
}
if (mysqli_num_rows($result) > 0)
{
?>
<table class="table table-sm" width="145%">
<thead>
<tr>
<th>Wrin</th>
<th>Descrizione</th>
<th>Contenuto</th>
<th>Quantità</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_assoc($result))
{
$soggetto = $row['modulo']."_".$row['wrin'];
$class = in_array($soggetto, $files) ? 'pdfbassa' : 'nopdfbassa';
echo "<tr class='testo_light2 " . $class . "'>
<td>".$row['wrin']."</td>
<td>".$row['descrizione']."</td>
<td>".$row['contenuto']."</td>
<td>".$row['quantita']."</td>
<td>".$row['note']."</td>
</tr>";
}
?>
</tbody>
</table>
N.B. potrebbe essere necessario aggiustare qualcosa, non so esattamente come sono i dati che recuperi.