I have a file editing modal where I show each file related to that specific ID
<tbody>
<?php
while ($row2 = mysqli_fetch_assoc($resul)) {
echo "<tr>";
echo "<td>".$row2["id_actividad"]."</td>";
echo "<td>".$row2["nombre"]."</td>";
echo "<td>".$row2["descripcion"]."</td>";
echo "<td>".$row2["objetivo"]."</td>";
echo "<td>".$row2["cursos"]."</td>";
echo "<td>".$row2["seccion"]."</td>";
echo "<td>".$row2["codigo"]."</td>";
echo "<td>".$row2["fecha"]."</td>";
echo "<td>".$row2["comuna"]."</td>";
echo "<td>".$row2["numero_estudiantes"]."</td>";
echo "<td>".$row2["socio"]."</td>";
echo "<td>
<a><i class='material-icons' style='color:black;cursor:pointer;cursor:hand' data-toggle='modal' data-target='#myModal2' data-otrawea='".$row2['id_actividad']."'>attach_file</i></a>
<a>
<i class='material-icons' style='color:black;cursor:pointer;cursor:hand' data-toggle='modal' data-target='#update' data-idactividad='".$row2['id_actividad']."' data-nombresu='".$row2['nombre']."' data-descripcionu='".$row2['descripcion']."' data-objetivou='".$row2['objetivo']."' data-cursosu='".$row2['cursos']."' data-seccionu='".$row2['seccion']."' data-codigou='".$row2['codigo']."' data-fechau='".$row2['fecha']."' data-comunau='".$row2['comuna']."' data-numeroestudiantesu='".$row2['numero_estudiantes']."' data-sociou='".$row2['socio']."'>mode_edit</i>
</a>
<a href='index.php?id=".$row2['id_actividad']."&opcion=1'><i class='material-icons' style='color:black;cursor:pointer;cursor:hand'>delete</i></a>
</td>";
echo "</tr>";
}
?>
</tbody>
<div id="myModal2" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<input type="text" id="otrawea" name="otrawea" style="display:none">
<h4 class="modal-title">Archivos</h4>
</div>
<div class="modal-body" id="mostrar">
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<script>
function consultar_archivo(){
var otrawea= document.getElementById("otrawea").value;
var data = '&otrawea='+otrawea;
$.ajax({
type: 'POST',
url: 'php/consultar_archivos.php',
data: data,
beforeSend: function() {
console.log('enviando datos a la BD...');
},
success: function(data) {
$('#mostrar').html(data);
}
})
return false;
};
setInterval(function cargar(){
consultar_archivo();
},10);
</script>
consultar_archivos.php
require_once "../conexion.php";
$conexion=conexion();
$otrawea = $_POST['otrawea'];
//EJECUTAMOS LA CONSULTA DE BUSQUEDA
mysqli_query($conexion,"SET NAMES 'utf8'");
$registro = mysqli_query($conexion,"SELECT file, id_imagen FROM imagen where id_actividad_imagen='$otrawea'");
mysqli_query($conexion,"SET NAMES 'utf8'");
echo "<table class='table table-bordered table-striped table-hover'>
<thead style='background-color: #616161;color: #F0F0F0;'>
<tr>
<th style='text-align: center;'>Id archivo</th>
<th style='text-align: center;'>Nombre archivo</th>
<th style='text-align: center;'></th>
</tr>
</thead>";
while($registro2 = mysqli_fetch_array($registro)){
mysqli_query($conexion,"SET NAMES 'utf8'");
echo "<tr>
<td style='text-align: center;'>".$registro2['id_imagen']."</td>
<td style='text-align: center;'>".$registro2['file']."</td>
<td style='text-align: center;'><a>Eliminar</a></td>
</tr>";
}
echo '</table>';
?>
My question is how I can delete the file in a modal and tried in various ways, but it does not work for me. If someone can guide me or give some example to guide me