This should work for you:
Here I first add all files to the array $files. After this I array_filter() all files out which doesn't exists and take only unique files with array_unique().
At the end I just loop through all files with array_map() then since you don't have the path form the server root, but from the server disk, I just take the basename() (means the file name) and concatenate it with __DIR__ to include it.
<?php
    while ($row = mysqli_fetch_array($result)){
        $files[] = $row['filename'];
    }
    $files = array_unique(array_filter($files, function($v){
        return file_exists($v);
    }));
    array_map(function($v){
        require_once(__DIR__ . "/" . basename($v));
    }, $files);
?>