In the view I make a foreach to display the clients, as below:
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<th>Nome</th>
<th>Profissão</th>
<th>CPF</th>
<th>Tel. Celular</th>
<th>E-mail</th>
<th>Status</th>
</thead>
<tbody>
<?php foreach ($cliente as $cli) : ?>
<tr>
<td><?= $cli->nomecliente; ?></td>
<td><?= $cli->profissao; ?></td>
<td><?= $cli->cpf; ?></td>
<td><?= $cli->telcelular; ?></td>
<td><?= $cli->email; ?></td>
<td><?= $cli->status; ?></td>
<td>
<button type="button" title="Detalhes" href="<?= $cli->codcliente ?>" class="btn btn-info hidden-print" data-toggle="modal" data-target=".clientepf-modal-lg">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span></button></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
And clicking the details button opens the Modal with the complete information of the client:
<!-- Modal View Cliente -->
<div class="modal fade clientepf-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<!--<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>-->
<h4 class="modal-title" id="myModalLabel"><?= $cliente[0]->nomecliente; ?></h4>
<h4 class="modal-title">
<p><font size="2" face="helvetica">Status: <strong><?php echo $cliente[0]->status; ?></strong></font></p>
</h4>
</div>
<div class="modal-body">
<input type="hidden" id="codcliente" name="codcliente" value="<?= $cliente[0]->codcliente; ?>">
<div class="row">
<div class="col-md-3">
<p><font size="2" face="helvetica">Nome: <strong><?php echo $cliente[0]->nomecliente; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Nacionalidade: <strong><?php echo $cliente[0]->nacionalidade; ?></strong></font></p>
</div>
<div class="col-md-3" >
<p><font size="2" face="helvetica">Estado Civil: <strong><?php echo $cliente[0]->estadocivil; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Profissão: <strong><?php echo $cliente[0]->profissao; ?></strong></font></p>
</div>
</div>
<div class="row">
<div class="col-md-3">
<p><font size="2" face="helvetica">CPF: <strong><?php echo $cliente[0]->cpf; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">RG: <strong><?php echo $cliente[0]->id; ?></strong></font></p>
</div>
<div class="col-md-3" >
<p><font size="2" face="helvetica">NIS / PIS / PASEP: <strong><?php echo $cliente[0]->pis; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">CTPS: <strong><?php echo $cliente[0]->ctps; ?></strong></font></p>
</div>
</div>
<div class="row">
<div class="col-md-3">
<p><font size="2" face="helvetica">Endereço: <strong><?php echo $cliente[0]->endereco; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Número: <strong><?php echo $cliente[0]->numero; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Complemento: <strong><?php echo $cliente[0]->complemento; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Bairro: <strong><?php echo $cliente[0]->bairro; ?></strong></font></p>
</div>
</div>
<div class="row">
<div class="col-md-3">
<p><font size="2" face="helvetica">Cidade: <strong><?php echo $cliente[0]->cidade; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Estado: <strong><?php echo $cliente[0]->estado; ?></strong></font></p>
</div>
<div class="col-md-3" >
<p><font size="2" face="helvetica">Cep: <strong><?php echo $cliente[0]->cep; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Email: <strong><?php echo $cliente[0]->email; ?></strong></font></p>
</div>
</div>
<div class="row">
<div class="col-md-3">
<p><font size="2" face="helvetica">Tel. Celular: <strong><?php echo $cliente[0]->telcelular; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Tel. Residencial: <strong><?php echo $cliente[0]->telresidencial; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Tel. Comercial: <strong><?php echo $cliente[0]->telcomercial; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Email Secundário: <strong><?php echo $cliente[0]->emailsecundario; ?></strong></font></p>
</div>
</div>
<div class="row">
<div class="col-md-3">
<p><font size="2" face="helvetica">Site: <strong><?php echo $cliente[0]->site; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Rede Social: <strong><?php echo $cliente[0]->redesocial; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Data de Nascimento: <strong><?php echo $cliente[0]->dtnascimento; ?></strong></font></p>
</div>
</div>
<div class="row">
<div class="col-md-3">
<p><font size="2" face="helvetica">Pai: <strong><?php echo $cliente[0]->nomepai; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Mãe: <strong><?php echo $cliente[0]->nomemae; ?></strong></font></p>
</div>
<div class="col-md-3">
<p><font size="2" face="helvetica">Observação: <strong><?php echo $cliente[0]->obs; ?></strong></font></p>
</div>
<div class="col-md-3" >
<p><font size="2" face="helvetica">Dt. Cadastro: <strong><?php echo $cliente[0]->dtcadastro; ?></strong></font></p>
</div>
</div>
<div class="modal-footer">
<button type="button" title="Imprimir" class="btn btn-primary hidden-print" onclick="myFunction()">
<span class="glyphicon glyphicon-print" aria-hidden="true"></span></button>
<button type="button" class="btn btn-default btn-sm hidden-print" data-dismiss="modal">Fechar</button>
</div>
</div> <!-- modal-body -->
</div> <!-- modal-content -->
</div> <!-- modal-dialog modal-lg -->
</div> <!-- modal fade clientepf-modal-lg -->
It happens that Modal is only displaying the first Customer in the list when clicking the details button of any client.
How do I make the detail button for each customer in the list display information for the selected customer? Thank you in advance!