Currently I have a code that extracts the last image modification path of each user, this extracted from a folder and a subfolder created with the id of each user (files / id / imagen.jpg). I do not keep the last route in Bd.
This is the code:
/* el id especifica de que usuario quieres mostrar la imagen*/
$id = 11;
$path = "files/".$id;
if(file_exists($path)){
$directorio = opendir($path);
while ($archivo = readdir($directorio)){
if (!is_dir($archivo)):
$archivos[filemtime($path.'/'.$archivo)] = $path.'/'.$archivo;
endif;
}
closedir($directorio);
//Ordenar el array
ksort($archivos);
//Buscar la última modificacida
$ultimaModificada = end($archivos);
//Compara todas las URLs y solo muestra la última modificada
foreach ($archivos as $archivo){
if ($archivo == $ultimaModificada){?>
<div data="<?php echo $path; ?>-<?php echo $archivo; ?>">
</div>
<img src="<?php echo utf8_encode($archivo); ?>" width='200' height='200' 'image-align:center' />
<?php
}
}
}
?>
This code only shows you the image of a single user and I want you to show me all the images that I have in the root (files / id) for each user by id in a table.
Something like this:
require 'enlace.php';
$id = $_GET['id'];
$sql = "SELECT id FROM personas";
$resultado = $mysqli->query($sql);
$row = $resultado->fetch_array(MYSQLI_ASSOC);
<div class="container">
<div class="row table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr class = "warning">
<th>Foto</th>
</tr>
</thead>
<tbody>
<?php while($row = $resultado->fetch_array(MYSQLASSOC))
{ ?>
<tr>
<td> <div class="main">
<form id="uploadimage" style="text-align:center" action="" method="post" enctype="multipart/form-data">
<td> $id = isset($_POST['id']);
$path = "files/".$id;
if(file_exists($path)){
$directorio = opendir($path);
while ($archivo = readdir($directorio)){
if (!is_dir($archivo)):
$archivos[filemtime($path.'/'.$archivo)] = $path.'/'.$archivo;
endif;
}
closedir($directorio);
//Ordenar el array
ksort($archivos);
//Buscar la última modificacida
$ultimaModificada = end($archivos);
//Compara todas las URLs y solo muestra la última modificada
foreach ($archivos as $archivo){
if ($archivo == $ultimaModificada){?>
<div data="<?php echo $path; ?>-<?php echo $archivo; ?>">
</div>
<img src="<?php echo utf8_encode($archivo); ?>" width='200' height='200' 'image-align:center' />
<?php
}
}
}
?> </td>
</tr>
<?php } ?>
</tbody>
The problem is in the id.
Thank you.
Greetings.