I need to bring from the database only the records that are connected to a certain id and display them in a table. In jsp, js.
I enclose my function that lists all the records that I have in the table (database), and when I click on the dynamic button, I take the id of the loan and send me to show in another table only the items of that loan.
<script >
function detalleSeleccionado(id_profe) {
$('.modal-trigger').leanModal();
$.get("Pc", {"opc": 2}, function (id_profe) {
var x = JSON.parse(id_profe);
$("#tbldetpres tbody tr").remove();
for (var i = 0; i < x.length; i++) {
$("#tbldetpres").append("\
<tr><td>" + (i + 1) + "</td>\n\
<td>" + x[i].nom_alumno + "</td>\n\
<td>" + x[i].fe_prestamo + "<br>" + x[i].hora_pre + "</td>\n\
<td>" + x[i].fe_devolucion + "<br>" + x[i].hora_devo + "</td>\n\
<td><a href='#modal3' onclick='listarproducto(" + x[i].idprestamo + ")'
class='waves-effect waves-light modal-trigger'><i class = 'material-icons prefix'>remove_red_eye</i></a></td></tr>");
}
});
}
</ script>