0
Good morning.
Guys, I got a little problem here.
I am showing in the view a table, where if a column has a certain status will show a link to open a model where will be shown the data that are in the database.
I gave a var_dump in the array and the data is coming correct, but it does not take the related Row data at the foreach position, it always repeats as if it were the first line.
VIEW>
<?php if($role['dr_status'] == "3") { ?>
<!-- <?php $desligamento = $this->Clinic_model->get_cancel_description($role['dr_id']); ?>
<?php var_dump($desligamento) ?> -->
<span style="color: red; font-weight:600"><?php echo "Desligamento solicitado" ?>
<a data-toggle="modal" data-target="#exampleModal">
<span style="margin-left: 10px; cursor: pointer"> ver motivo </span>
</a>
</span>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header" style="background-color: #00C0EF; color: white; font-weight: 600">
<h5 class="modal-title" id="exampleModalLabel" style="font-weight: 600">Desligamento solicitado</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" style="font-weight: 600">
<p> <?php echo $role['cancel']; ?> </p>
</div>
<div class="modal-footer col-12">
<p> Deseja realmente desligar esse médico </p><br>
<button type="button" class="btn btn-danger">SIM</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Voltar</button>
</div>
</div>
</div>
</div>
<?php } ?>
this is the table I’m creating, when click on details opens the modal >
And here’s the problem all the modals always show the same data, I think it’s related to the DOM, but I couldn’t solve the problem. Preferably if done in php itself.
thank you.
You are using ajax to make data requests?
– Vinicius De Jesus
no, I’m using php itself with codeigniter framework.
– jona1has
I suggest that each link has an id, and that when you click on the link open a modal run an ajax that does the query in the database and print in the body of the modal.
– Vinicius De Jesus