I made a small system where the administrator "sends" documents to a certain user, where he sends the info to a DB and generates a folder with the user ID. In the image below is the BD responsible for recording the information of the files sent, such as URL, File Name, Description and the user ID to which the file was sent, which is in the Identification table.
Whentheclientaccessesyouradministrativepart,IwanttolistthedocumentsthathavethesameIDofthesame,inthecaseofcomparingtheSESSIONIDandListdocumentsthathavethesameID.
Belowthepagewhereyoulistthedocuments,butnotthewayIwantthem,becauseIcannotputthedownloadlinkordescription.
require_once'conexao.php';include("includes/header.php");
$query = mysql_query("SELECT * FROM usuarios WHERE usuario = '$_SESSION[usuario]' AND senha = '$_SESSION[senha]'") or die(mysql_error());
$cliente = mysql_fetch_assoc($query);
$query = mysql_query("SELECT nome,url FROM arquivos") or die(mysql_error());
$arquivos = mysql_fetch_assoc($query);
$urlbd = $arquivos['url'];
$id = $cliente['id'];
$nome = $arquivos['nome'];
$dir = "../../restrito/adm/uploads/$id";
$url = "../../restrito/adm/uploads/$id/$nome";
$pasta = opendir($dir);
/* Loop para ler os arquivos do diretorio */
while ($arquivo = readdir($pasta)){
/* Verificacao para exibir apenas os arquivos e nao os caminhos para diretorios superiores */
if ($arquivo != '.' && $arquivo != '..'){
/* Escreve o nome do arquivo na tela */
echo "<a href='$urlbd' target='_blank'>$arquivo</a><br>";
}
}