-1
I am new in PHP and I am having a lot of difficulties in displaying the database information through a modal, I am accessing the database
by a foreach
, but the problem is that it only displays the modal with the last record.
excerpt from the code:
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>#Id</th>
<th>Nome | Paciente</th>
<th>Data</th>
<th>Exame</th>
<th>Médico Solicitante</th>
<th>Convênio</th>
</tr>
</thead>
<?php foreach($dwl->findAll() as $value):?>
<tbody>
<tr>
<td><?php echo $value->co_patientid; ?></td>
<td><?php echo $value->na_patientname; ?></td>
<td><?php echo $value->na_studydate; ?></td>
<td><?php echo $value->na_description; ?></td>
<td><?php echo $value->na_requestername; ?></td>
<td><?php echo $value->na_insuranceplan; ?></td>
<td>
<button type="button" class="btn btn-danger">Excluir</button>
<button type="button" class="btn btn-warning">Editar</button>
<button type="button" class="btn btn-info" data-toggle="modal" data-target="#ModalView-<?php echo $value->co_patientid; ?>">Visualizar</button>
</td>
</tr>
</tbody>
<?php endforeach ; ?>
</table>
</div>
<div class="modal fade" id="ModalView-<?php echo $value->co_patientid; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalWorkView"><td>Informações</td></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Fechar">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="table-responsive">
<p><b>#Id:</b> <?php echo $value->co_patientid; ?> </p>
<p><b>Paciente:</b> <?php echo $value->na_patientname; ?> </p>
<p><b>Data do Exame:</b> <?php echo $value->na_studydate; ?> </p>
<p><b>Descrição Exame:</b> <?php echo $value->na_description; ?> </p>
<p><b>Médico Solivitante:</b> <?php echo $value->na_requestername; ?> </p>
<p><b>Convênio:</b> <?php echo $value->na_insuranceplan; ?> </p>
<p><b><hr></b></p>
<p><b>Comentário</p></b>
<p><?php echo $value->na_comment; ?> </p>
</div>
</div>
</div>
</div>
</main>